private void RunServer() { TcpListener listener = new TcpListener(IPAddress.Any,this._port); Debug.WriteLine("ServerAcceptor| Listening on port: " + this._port); listener.Start(); while(!Close) { if (listener.Pending()) { TcpClient client = listener.AcceptTcpClient(); ServerSocket serverSocket = new ServerSocket(this, client); this._sClients.Add(serverSocket); } else Thread.Sleep(100); } foreach(ServerSocket sClient in this._sClients) { sClient.Close(); } }
public void RemoveSocket(ServerSocket socket) { _sClients.Remove(socket); if (_sClients.Count == 0) Close = true; }