Пример #1
0
 /// <summary>
 /// One thread will be assigned to
 /// handling new connections and will create a new
 /// ClientConnection object for every new connection.
 /// </summary>
 /// <param name="serverSocket">The socket to listen for
 /// incoming connections</param>
 /// <param name="chatroomList">The current chatroomList</param>
 private static void handleIncomingConnections(
     TcpListener serverSocket, ChatroomList chatroomList)
 {
     try
     {
         while (true)
         {
             TcpClient socket = serverSocket.AcceptTcpClient();
             Console.WriteLine("A new client has connected");
             NetworkStream    stream = socket.GetStream();
             ClientConnection client
                 = new ClientConnection(stream, chatroomList);
             client.StartAsync();
         }
     }
     catch (ThreadAbortException tae) {}
     catch (SocketException se) {}
 }