Re: Can NetworkStream.Write() block?
- From: Gaz <random@xxxxxxxxxx>
- Date: Sat, 19 Jan 2008 18:37:16 +0000
Jesse Houwing wrote:
Hello GAZ,
myNetworkStream.Write(byte[], int offset, int size);
From the MSDN documentation:
"
Remarks:
The Write method starts at the specified offset and sends size bytes
from the contents of buffer to the network. The Write method blocks
until the requested number of bytes is sent or a SocketException is
thrown. If you receive a SocketException, use the
SocketException.ErrorCode property to obtain the specific error code,
and refer to the Windows Sockets version 2 API error code
documentation
in MSDN for a detailed description of the error.
"
It says the call blocks until the bytes are sent but aren't the bytes
just queued to the write buffer until the OS feels like sending them
over the wire? Therefore doesn't the call always return pretty much
immediately anyway?
My guess is that it'll block if the buffer is full.
--
Jesse Houwing
jesse.houwing at sogeti.nl
Thank you.
It seems this is better than using the non-blocking version myNetworkStream.BeginWrite(byte[] buffer, int offset, int size) since all that does (if the write buffer is full) is create a backlog of BeginWrite threads all waiting to complete. And what happens when /that/ buffer is full? another blockage?
Might as well use the blocking version and increase the buffer size if that is possible.
.
- Follow-Ups:
- Re: Can NetworkStream.Write() block?
- From: Jeroen Mostert
- Re: Can NetworkStream.Write() block?
- References:
- Can NetworkStream.Write() block?
- From: Gaz
- Re: Can NetworkStream.Write() block?
- From: Jesse Houwing
- Can NetworkStream.Write() block?
- Prev by Date: Re: Can NetworkStream.Write() block?
- Next by Date: Re: missing code from IL
- Previous by thread: Re: Can NetworkStream.Write() block?
- Next by thread: Re: Can NetworkStream.Write() block?
- Index(es):
Relevant Pages
|