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



Joseph Dionne wrote:
One can read a socket non blocked, using a single method call, receiving either data, or no data.

or some data. There is a third state.

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.

or when you have something better to do in non-blocking mode than wait for the client to empty his receive buffer. Also, at some point you want to decide that this is never going to happen and you prefer to give up.


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.

Nevertheless that is how both the non-blocking read and non-blocking write calls behave on a socket. There are three states in both, and technically your statement does not hold water.


and BTW what exactly is a socket MCB?
.



Relevant Pages

  • 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
    ... 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. ... 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. ... I'm pretty sure no one desires half of the STREAM delivered to the remote client. ...
    (comp.lang.java.programmer)
  • Re: A problem of UDP
    ... Probably an exceptionally poor decision. ... UDP is ill-suited for this purpose. ... Here is my code to start a socket: ... setsockopt, "Fail to enable broadcasting.", ...
    (microsoft.public.vc.mfc)
  • Re: connect() always returns true (0)
    ... Check for a valid Ethernet address... ... to bind an outgoing socket anyway. ... Why are you expecting the connection to fail? ... Win32 app is a connectcall relating to sockets. ...
    (microsoft.public.windowsce.embedded)
  • RE: C# Socket Problem
    ... An existing connection was forcibly closed by the remote host. ... SO_LINGER option on the remote socket). ... Subsequent operations fail with WSAECONNRESET. ... at System.Net.Sockets.NetworkStream.Read(Bytebuffer, Int32 offset, ...
    (microsoft.public.dotnet.languages.csharp)