예제 #1
0
        public static void listenerThread(object port)
        {
            try
            {
                newListener = new TcpListener(IPAddress.Any, (int)port);
                newListener.Start();
                TcpClient client;
                while (true)
                {
                    client = newListener.AcceptTcpClient();

                    if (client == null)
                    {
                        break;
                    }

                    threadPool.addClient(client);
                }
            }
            catch
            {
                Console.WriteLine("Listener ending");
            }
        }
예제 #2
0
        public static void listenerThread(object port) //listener thread constantly executes this
        {
            try
            {
                newListener = new TcpListener(IPAddress.Any, (int)port); //open a tcp Listener
                newListener.Start();
                TcpClient client;
                while (true)
                {
                    client = newListener.AcceptTcpClient(); //have listener keep trying to get a new client

                    if (client == null)
                    {
                        break;
                    }

                    threadPool.addClient(client); //if not null, send the client to the threadpool
                }
            }
            catch
            {
                Console.WriteLine("Listener ending");
            }
        }