private void HandleClient(object obj) { // retrieve client from parameter passed to thread TcpConnention conn = (TcpConnention)obj; TcpClient client = conn.client; // sets two streams // you could use the NetworkStream to read and write, // but there is no forcing flush, even when requested OnWelcomeMessage?.Invoke(conn); while (client.Connected && _isRunning) { Thread.Sleep(1000); } _hashTable.Remove(conn.ipAddr); }
private void HandleClient(object obj) { // retrieve client from parameter passed to thread TcpConnention conn = (TcpConnention)obj; TcpClient client = conn.client; // sets two streams // you could use the NetworkStream to read and write, // but there is no forcing flush, even when requested String sData = null; OnWelcomeMessage?.Invoke(conn); while (client.Connected) { // reads from stream sData = conn.sReader.ReadLine(); // shows content on the console. Console.WriteLine("Client > " + sData); } _hashTable.Remove(conn.ipAddr); }