private void ServerListener() { Socket clientSocket = null; TCPServerClient clientHandler; while (listening) { try { // Wait for any client requests and if there is any // request from any client accept it (wait indefinitely) clientSocket = listener.AcceptSocket(); // Create a socket listener object for the client clientHandler = new TCPServerClient(clientSocket); clientHandler.OnLog += ClientLog; // Add the socket listener to an array list in a thread safe fashion lock (clientList) { clientList.Add(clientHandler); } // Start communicating with the client in a different thread clientHandler.Start(); } catch (SocketException se) { //throw; } } }
public void ClientLog(TCPServerClient t, LogEventArgs e) { log(e.Text); }