المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Waiting for response in NetworkStream



C# Programming
05-23-2009, 11:50 PM
Hi,

I've made a kind of telnet class that has these methods:
+Connect()
+string Response() : Reads the stream
+string SendMessage() : Writes to the stream and calls response()

The problem is that if call response and there is no response, I get stuck..
I tried using networkStream.DataAvailable but still gets stuck,

algo tried making a
while (timespan.Seconds < timeout) {
..
}

But still.

For example if I conncet to a POP server, this could happend.
I say: RETR 2
1st line of response
I ask another line of response (calling Response())
2nd line of response
Repeat these last two lines until...
I ask another line of response
-here it gets stuck because there arent more lines-