Been a long time sence I last posted here, got alot better at C# than I used to be.
I am creating a simple server and client program. The client connects to the server (both running on my computer) and that works fine, they can connect without errors.
And as far as I can tell I can send data using a networkstream and laying a streamreader and/or streamwriter over it.
But when I go to read a line of data the program freezes or acts as if it is constantly trying to do somthing (like writing a 1gb file). I waited for a couple mins to see if I could grab an exception but none came, it just sat there frozen.
writing code:
Code:if (host == false) { clientwriter.Write(textBox_TextWrite.Text); clientwriter.Flush(); } else { serverwriter.Write(textBox_TextWrite.Text); clientwriter.Flush(); }
reading code:
if you need more code just ask.Code:if (host == false) { textBox_TextRead.Text = clientreader.ReadToEnd(); } else { try { textBox_TextRead.Text = serverreader.ReadLine(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }



LinkBack URL
About LinkBacks



If it's pausing on ReadLine(), that probably means it's waiting until it reaches the end of the line. Try changing it to Read(), or ensure a '\n' or '\r\n' (preferably use Environment.NewLine) is sent at the end of the text.