[Mono-list] System.Net.Sockets.NetowrkStream
Flaw/Inconsistency/Wierdness
Gonzalo Paniagua Javier
gonzalo.reply.to.the.list.iam.subscribed@ximian.com
Tue, 03 Aug 2004 19:30:03 -0400
El mar, 03-08-2004 a las 17:35, Scott Manley escribió:
> So the NetworkStream class sits on top of the Socket class and provides
> a stream like interface, one of the methods has a problem which probably
> needs fixing to make the class halfway useful.
>
> The Write method is supposed to let us write data to an open stream and
> does this by calling Send on the underlying socket.....
>
> public override void Write (byte [] buffer, int offset, int size)
> {
> ...
> ...
> ...
> try {
> socket.Send (buffer, offse, size, 0);
> } catch (Exception e) {
> throw new IOException ("Write failure", e);
> }
> }
>
> However it's possible for Send to write less than the requested amount
> of data to the socket, it returns the number of bytes written - since
> the Write method returns void we should be ensuring the write is
> complete before leaving the function. Otherwise you end up like me and
> spend hours wondering why NetworkStream objects sometimes lose data.....
> So we need to wrap our socket.Send with enough logic to handle
> potentially multiple writes...
Can you file this as a bug report? (http://bugzilla.ximian.com) And if
you have a test case, please, attach it. Thanks.
-Gonzalo