Click to See Complete Forum and Search --> : When To Read from StreamReader


wainwrightwt
May 22nd, 2008, 10:55 AM
I have a client app that interacts with a TELNET-like server.

I'm using a streamwriter to send a request, and a streamreader to get the response.

This is working for the most part, but occasionally the streamreader seems to be "reading to soon". Meaning the full response has not been posted to the stream.

My reader code is as follows:

while (sr.Peek() >= 0)
{
strBuffer.Append(sr.ReadLine());
}

Every once in a while the loop will exit without getting the full response.

What should I do? Thanks.

boudino
May 23rd, 2008, 01:53 AM
I'm affraid, that while you are unable to use some communication platform like WCF or .NET Remoting (which seems to be your case), there is not much what you can do. U think that only way is to do it low-level and manage socets on your own.