コード例 #1
0
ファイル: TelnetServer.cs プロジェクト: HarryCordewener/MUA
        private void ClientListener()
        {
            try
            {
                Start(); // Start listening.
                while (true)
                {
                    // Buffer for reading data
                    Console.WriteLine("Waiting for a connection... ");
                    // Perform a blocking call to accept requests.
                    // You could also user server.AcceptSocket() here.

                    var client = new TCPInitializer.Client(AcceptTcpClient(), Metadata);
                    AllClients.Add(client);

                    Thread clientThread = new Thread(StreamHandler);
                    clientThread.Start(client);


                    // Shutdown and end connection
                    // AllClients.Disconnect(client);
                }
            }
            catch (SocketException e)
            {
                Console.WriteLine("SocketException: {0}", e);
            }
            finally
            {
                // Stop listening for new clients.
                Stop();
                AllClients.Disconnect(Metadata);
            }
        }