Beispiel #1
0
        private static void AcceptCallback(IAsyncResult IAR)
        {
            Socket Server, handler;

            try
            {
                Server  = (Socket)IAR.AsyncState;
                handler = Server.EndAccept(IAR);
            }
            catch (ObjectDisposedException ode)
            {
                ExceptionBuffer.Add(ode);
                return;
            }

            allDone.Set();

            string sKey = TcpAsyncCommon.DefaultUID + ++iAcceptCounter;

            StateObject state = new StateObject();

            state.workSocket = handler;
            state.key        = sKey;

            D2Sockets.Set(sKey, state);
            D2TReceive.Set(sKey, null);
            D2TSend.Set(sKey, null);
            D3BReceive.Set(sKey, new DataBuffer());
            D3BSend.Set(sKey, new DataBuffer());
        }
Beispiel #2
0
        private void AcceptCallback(IAsyncResult IAR)
        {
            Socket Server, handler;

            try
            {
                Server  = (Socket)IAR.AsyncState;
                handler = Server.EndAccept(IAR);
            }
            catch (ObjectDisposedException ode)
            {
                Exceptions.Write(ode);
                return;
            }

            allDone.Set();

            string sKey = TcpAsyncCommon.DefaultUID + TickTime.NowTicks;

            StateObject state = new StateObject();

            state.workSocket = handler;
            state.key        = sKey;

            D2Sockets.Set(sKey, state);
            D3BReceive.Set(sKey, new BufferedArray <byte[]>(this.Length));
            D3BSend.Set(sKey, new BufferedArray <byte[]>(this.Length));
        }
Beispiel #3
0
        private void Accept()
        {
            Socket handler = Listener.Accept();
            string key     = TcpAsyncCommon.DefaultUID + TickTime.NowTicks;

            StateObject state = new StateObject();

            state.workSocket                   = handler;
            state.workSocket.NoDelay           = TcpAsyncServer.NoDelay;
            state.workSocket.SendBufferSize    = TcpAsyncServer.PacketSizeTCP;
            state.workSocket.ReceiveBufferSize = TcpAsyncServer.PacketSizeTCP;
            state.workSocket.SendTimeout       = TcpAsyncServer.SendTimeout;
            state.workSocket.ReceiveTimeout    = TcpAsyncServer.ReceiveTimeout;
            state.workSocket.Ttl               = TcpAsyncServer.Ttl;
            state.key  = key;
            state.Time = TickTime.Now;

            D2Sockets.Set(key, state);
            D3BReceive.Set(key, new BufferedArray <byte[]>(this.Length));
            D3BSend.Set(key, new BufferedArray <byte[]>(this.Length));

            //this.Send(key, "#START".GetBytes());
        }