N
Nicholas Paldino [.NET/C# MVP]
White Spirit,
I find that when it comes to socket-based streams, you can't use stream
readers to do this. They try and buffer bytes from the stream, no matter
what the underlying stream is. Since the socket disconnects, and you call
ReadLine, the StreamReader hangs on the call to Read on the stream, waiting
for the new line combo.
I recommend using the NetworkStream, and reading byte by byte yourself,
parsing apart the new line on your own. If the socket disconnects, then no
more bytes will be returned to you (if the socket is closed).
Hope this helps.
I find that when it comes to socket-based streams, you can't use stream
readers to do this. They try and buffer bytes from the stream, no matter
what the underlying stream is. Since the socket disconnects, and you call
ReadLine, the StreamReader hangs on the call to Read on the stream, waiting
for the new line combo.
I recommend using the NetworkStream, and reading byte by byte yourself,
parsing apart the new line on your own. If the socket disconnects, then no
more bytes will be returned to you (if the socket is closed).
Hope this helps.