[Mono-dev] NetworkStream.Read() bug?
Jonathan Shore
jonathan.shore at gmail.com
Tue Mar 12 23:56:22 UTC 2013
Hi,
I have an application that uses a NetworkStream on a Socket and has a loop vaguely like (I am decomposing more abstract calls here):
while (some condition)
{
var n = stream.Read (buffer, 0, len);
<do something with buffer>
}
The odd thing is that sometimes Read() returns 0, even when the stream is clearly not closed. I verified this by looping until n > 0 in a reproducable situation. This is on a synchronous socket, so returning 0 should only happen when we hit the end of stream.
I have not set the stream to be non-blocking and this is a synchronous operation. Is there any reason why I should ever get 0 back aside from connection closure / loss?
Note that I am using 3.0.2 on OSX. [ 3.0.3 and up has a bug in Socket_2_1.cs which I posted (and posted a patch) 3 months ago. I cannot upgrade my mono runtime until that is fixed. Bug 9520 BTW: ]
Thanks for any pointers
Jonathan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-devel-list/attachments/20130312/33ec1854/attachment.html>
More information about the Mono-devel-list
mailing list