Re: Non-blocking method for reading writing objects to sockets



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.
.




Relevant Pages

  • Re: Problems with French electricity
    ... Did the French socket have an earth connection..lack of earth will make the ... MCB trip out? ... The fridge worked perfectly on gas and the mains sockets were ... Reversed polarity on the socket on the French site? ...
    (uk.rec.motorcaravans)
  • Re: Non-blocking method for reading writing objects to sockets
    ... 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. ... This is not an error condition. ...
    (comp.lang.java.programmer)
  • Socket send problem (ucLinux)
    ... I have a listen socket that can send data to a remote client. ... I noted that when i disrupt the network connection the transfer ... does it occur between 2 linux desktop machines. ...
    (comp.os.linux.embedded)
  • Re: Non-blocking method for reading writing objects to sockets
    ... 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. ... I'm pretty sure no one desires half of the STREAM delivered to the remote client. ...
    (comp.lang.java.programmer)
  • Re: WSAGetOverlappedResult() returns true when remote client closes the socket
    ... blocked socket ... Arkady ... As exspected I get the WSA_IO_PENDING and WSAGetOverlappedResult waits ... But when the remote client closes the socket I was ...
    (microsoft.public.win32.programmer.networks)