Esempio n. 1
0
        private void OnAcceptSocket(IAsyncResult ar)
        {
            try
            {
                Socket socket = _listener.EndAcceptSocket(ar);
                if (socket.Connected)
                {
                    if (SocketConnectionCheck.CheckConnection(socket, MaxIpConnectionCount, AntiDDosStatus))
                    {
                        socket.NoDelay = _disableNagleAlgorithm;
                        AcceptedConnections++;

                        ConnectionData connectionInfo = new ConnectionData(socket, _parser.Clone() as IDataParser,
                                                                           AcceptedConnections)
                        {
                            Disconnected = OnChannelDisconnect
                        };
                        OnClientConnected(connectionInfo);
                    }
                }
            }
            catch
            {
                // ignored
            }

            try
            {
                _listener?.BeginAcceptSocket(OnAcceptSocket, _listener);
            }
            catch
            {
                // ignored
            }
        }