Exemplo n.º 1
0
 private bool Unbind(SocketWrapper wrapper, SocketError?code = null)
 {
     if (code != null)
     {
         wrapper.WrapperOnSocketError?.Invoke(code.Value);
     }
     if (!WrapperList.Remove(wrapper))
     {
         return(false);
     }
     NativeLookup.Remove(wrapper.Socket);
     wrapper.Local = wrapper.Remote = null;
     SocketCount--;
     if (ClientLookup.Remove(wrapper, out Connection connection))
     {
         ClientCount--;
         wrapper.EndedReadable = true;
         wrapper.EndedWritable = true;
         wrapper.ClientOnClose?.Invoke();
     }
     wrapper.State = WrapperState.Destroyed;
     if (ServerLookup.Remove(wrapper))
     {
         ServerCount--;
     }
     return(false);
 }
Exemplo n.º 2
0
 private bool Bind(SocketWrapper wrapper)
 {
     SocketCount++;
     WrapperList.Add(wrapper);
     NativeLookup.Add(wrapper.Socket, wrapper);
     return(GotFirst = true);
 }
Exemplo n.º 3
0
 public void ClientOpen(SocketWrapper referer, Connection connection)
 => BoundThread.Enqueue(new IOOperation()
 {
     Callee     = this,
     Referer    = referer,
     Connection = connection,
     Type       = OperationType.ClientOpen,
 });
Exemplo n.º 4
0
        private SocketWrapper Create()
        {
            IPEndPoint endPoint = _base?.Local;

            _base = new SocketWrapper();
            _base.WrapperBind();
            _base.WrapperAddServer(this);
            _base.ServerExclusive      = Exclusive;
            _base.ServerBacklog        = Backlog;
            _base.WrapperOnSocketError = _OnError;
            _base.ServerOnConnection   = _OnConnection;
            if (endPoint != null)
            {
                _base.ServerLookup(endPoint);
            }
            return(_base);
        }
Exemplo n.º 5
0
 private bool Bind(Listener listener, SocketWrapper wrapper)
 {
     ServerCount++;
     ServerLookup.Add(wrapper, listener);
     return(true);
 }
Exemplo n.º 6
0
 private bool Bind(Connection connection, SocketWrapper wrapper)
 {
     ClientCount++;
     ClientLookup.Add(wrapper, connection);
     return(true);
 }