using System;
using System.Net.Sockets;
using System.Threading;
using System.Text;
public class MainClass
{
public static void Main()
{
int BufferSize = 256;
TcpClient tcpSocket = new TcpClient("127.0.0.1", 65000);
NetworkStream streamToServer = tcpSocket.GetStream();
System.IO.StreamWriter writer = new System.IO.StreamWriter(streamToServer);
writer.Write("message");
writer.Flush();
bool fQuit = false;
while (!fQuit)
{
char[] buffer = new char[BufferSize];
System.IO.StreamReader reader = new System.IO.StreamReader(streamToServer);
int bytesRead = reader.Read(buffer, 0, BufferSize);
if (bytesRead == 0)
fQuit = true;
else {
string theString = new String(buffer);
Console.WriteLine(theString);
}
}
streamToServer.Close();
}
}