Hi.
I am trying to some socket programs. Below, server side program's codes. Its getting the messages from client with no problem. I want to count this messages length and sending again to client. But it doesnt work. Where am I mistaken?
public NetworkStream str;
public StreamReader str_rdr;
public StreamWriter str_wrt;
public Socket clientsoket;
public void Form1_Load(object sender, EventArgs e)
{
CheckForIllegalCrossThreadCalls = false;
Thread thread_listener = new Thread(new ThreadStart(listen));
thread_listener.Start();
}
public void listen()
{
TcpListener listener = new TcpListener(30000);
while (true)
{
listener.Start();
Socket clientsocket = listener.AcceptSocket();
NetworkStream str = new NetworkStream(clientsoket);
StreamReader str_rdr = new StreamReader(str);
string var1 = str_rdr.ReadLine();
textBox1.Text = var1; // ----> In here, I am seeing client's message.
StreamWriter str_wrt = new StreamWriter(str);
str_wrt.WriteLine(textBox1.Text.Length);
str_wrt.Flush();
}
}