Example #1
0
        void ProcessAccept(SocketAsyncEventArgs e)
        {
            if (Server == null || Server.Stopped.IsTrue())
            {
                return;
            }

            Socket socket = null;

            if (e.SocketError != SocketError.Success)
            {
                if (SocketEx.IsIgnorableError(e.SocketError) == false)
                {
                    Logger.Error(string.Format("ProcessAccept:{0}", e.SocketError));
                }

                Task.Run(() => { e.AcceptSocket.CloseEx(); });

                e.AcceptSocket = null;
                Server.m_AcceptSAEAPool.Push(e);
                StartAccept();
                return;
            }

            socket = e.AcceptSocket;

            StartAccept();

            e.AcceptSocket = null;
            Server.m_AcceptSAEAPool.Push(e);

            if (socket != null)
            {
                OnAccepted(socket);
            }
        }