Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Blocking StreamReader.Read(...) in C#

Status
Not open for further replies.

jouhou

Programmer
Dec 7, 2006
1
CZ
Hi,im trying to implement unblocking reading from network stream, this causes me headaches:

StreamReader sr = new StreamReader(layer);
ret = sr.Read(buffer, 0, 1024);

Reads first 47 chars from network stream, it is end of line.
Next attempt will end in indefinite block.

Any attempt of:
sr.Peek(); - block too
sr.EndOfStream == true; - block too

Any attempt of reading, checking status from network stream causes freeze.

What to do ? Thanks.
 
Why are you still reading if it's the end of the transmission?

Is it a constant listener? This would need to be in a separate thread.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top