public void Listen() { TcpListener listener = new TcpListener(IPAddress.Any, Convert.ToInt32(ConfigurationManager.AppSettings["tcpPort"])); try { listener.Start(); int clientNr = 0; OnLogged("Waiting for a connection..."); while (continueProcess) { if (listener.Pending()) { TcpClient handler = listener.AcceptTcpClient(); if (handler != null) { OnLogged("Client #{0} accepted", ++clientNr); ClientHandler client = new ClientHandler(handler); client.Logged += Logged; connectionPool.Enqueue(client); } } Thread.Sleep(100); } } finally { listener.Stop(); } }
public void Enqueue(ClientHandler client) { syncdQ.Enqueue(client); }