Console.WriteLine("Starting echo server..."); int port = 1234; TcpListener listener = new TcpListener(IPAddress.Parse("192.168.2.162"),port); listener.Start(); TcpClient client = listener.AcceptTcpClient(); NetworkStream stream = client.GetStream(); StreamWriter writer = new StreamWriter(stream, Encoding.ASCII) { AutoFlush = true }; StreamReader reader = new StreamReader(stream, Encoding.ASCII); while (true) { string inputLine = ""; while (inputLine != null) { inputLine = reader.ReadLine(); writer.WriteLine("Echoing string: " + inputLine); Console.WriteLine("Echoing string: " + inputLine); } Console.WriteLine("Server saw disconnect from client."); Console.ReadLine(); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)