Ejemplo n.º 1
0
        internal bool AddClient( WebTCPClient Client )
        {
            if( Client == null )
              return false;

            Clients[ClientsLast] = Client;
            ClientsLast++;

            if( ClientsLast >= Clients.Length )
              {
              try
              {
              Array.Resize( ref Clients, Clients.Length + 512 );
              }
              catch
            {
            return false;
            }
              }

            // ShowStatus( "Added client at: " + ClientsLast.ToString() );
            return true;
        }
Ejemplo n.º 2
0
        private void QueueConnectedClient()
        {
            // MForm.ShowStatus( "Top of QueueConnectedClient()." );
            if( !IsEnabled )
              return;

            if( !Listener.Pending())
              return;

            WebTCPClient NewClient = null;

            try
            {
            TcpClient Client = Listener.AcceptTcpClient();

            // IPAddress.Parse(
            IPEndPoint EndPt = (IPEndPoint)(Client.Client.RemoteEndPoint);
            string Address = EndPt.Address.ToString();
            // int PortNum = EndPt.Port;
            Address = Address.Trim();

            MForm.NetStats.AddToPort80Count( Address );

            if( MForm.NetStats.IsBlockedAddress( Address ))
              {
              Client.Close(); // Disconnect this guy.
              return;
              }

            // See if it needs to update the DNS.
            StartSendingForDns( Address );

            NewClient = new WebTCPClient( MForm, Client, Address );
            // ShowStatus( "Queue Remote Address: " + Address );
            AddClient( NewClient );

            }
            catch( Exception Except )
              {
              ShowStatus( "Exception in QueueConnectedClient():\r\n" + Except.Message );

              if( NewClient != null )
            {
            // It could be in the Clients array, but it will get removed
            // if it is, since it's shut down.
            NewClient.FreeEverything();
            }
              }
        }