Re: Non-blocking method for reading writing objects to sockets
- From: Joseph Dionne <jdionne@xxxxxxxxxxx>
- Date: Sat, 07 May 2005 16:00:29 GMT
Esmond Pitt wrote:
Joseph Dionne wrote:
Technically there are not non blocking socket write methods in any language. There is either room enough in the socket write MCB to hold the data, allowing the method to return, or there is not enough room, and an error is returned to indicate a failure.
Technically and more accurately, there *are indeed* non-blocking socket write methods in both C and Java. In non-blocking mode, a socket write will put as much as it can of the application data into the socket send buffer without blocking and return that count, which can be zero if there was no room. This is not an error condition.
I don't know what is meant by 'MCB', it is not a term associated with sockets.
Either increase your transmit buffer size, which I believe defaults to 32kb
The default is platform dependent. It is 8k on Windows which is not sufficient.
, or find out why the data is not being transmitted to the network.
to which the answer can really only be that the client isn't reading fast enough, or at all.
One can read a socket non blocked, using a single method call, receiving either data, or no data. But, one cannot code a single method call to write non blocked in a "fire and forget" manner. Even you acknowledge that write might fail to emit all the data one attempted to write. So, one always needs to put a loop around socket write methods, terminating only after all data has been emitted.
That is why is said "technically". Conceptually, a non blocked socket read method is expected to do one of two things, return data, or indicate that no data is returned, while a socket write can have three states, all data written, some data written, no data written. Since "some data written" will a application error. I'm pretty sure no one desires half of the STREAM delivered to the remote client.
.
- Follow-Ups:
- Re: Non-blocking method for reading writing objects to sockets
- From: Esmond Pitt
- Re: Non-blocking method for reading writing objects to sockets
- References:
- Non-blocking method for reading writing objects to sockets
- From: Sameer
- Re: Non-blocking method for reading writing objects to sockets
- From: Joseph Dionne
- Re: Non-blocking method for reading writing objects to sockets
- From: Esmond Pitt
- Non-blocking method for reading writing objects to sockets
- Prev by Date: Re: Java consultant: Are we being conned? Please help!
- Next by Date: Re: Java consultant: Are we being conned? Please help!
- Previous by thread: Re: Non-blocking method for reading writing objects to sockets
- Next by thread: Re: Non-blocking method for reading writing objects to sockets
- Index(es):
Relevant Pages
|