StreamReader.ReadLine - It waits for a message?

ThePentiumGuy

Senior Contributor
Joined
May 21, 2003
Messages
1,113
Location
Boston, Massachusetts
Hey guys,
When I read from a stream (TCPClient.GetStream) using StreamReader.ReadLine, it (obviously) waits until it receives some text and then it continues.

Is there any way to do something like:
Streamreader.ReadLineButStopIfTheresNothingToRead ?

My chat program is going really well, just the server seems to hang on this line, and I can't really... do anything else (ex: AddUserWhenTheyConnect()).

-The Pentium Guy
 
TPG, if you aren't using asynchronous methods or threads, then it will stop on that statement and wait until someone does connect. Are you using it and it still stops there?
 
I dont know what asynchronous means, but all I know is that I do not wish for it to stop there, I just want to make it so that when the server receives a message - it'll process it, and franky I don't know where to start :P, besides checking in an infinate loop whether the message it received was blank or not (it becomes blank anways unless it receives a message, because that ReadLine line runs in its own thread... whch seems to confuse me becuase if it's running in its own thread then why is it not going to the AddClient sub?)

-The Pentium Guy
 
I'll upload some code (as an edit) to this post later when I am at my work pc. It's the help that I received from HJB on the same toppic.
 

Attachments

Last edited:
Back
Top