Re: Non-blocking method for reading writing objects to sockets
- From: Joseph Dionne <jdionne@xxxxxxxxxxx>
- Date: Sun, 08 May 2005 13:43:11 GMT
Esmond Pitt wrote:
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.
Only proxy like applications, providing connectivity between two end points, can truly read a socket STREAM without regard to message boundaries. At some point, even a socket read method requires a complete packet delivery.
As you may or may not know, not knowing the level of expertise you bring to this discussion, socket stream of non ASCII STREAMS, use two to four bytes preceding the data allowing the received to know the message size and prepare applications to receive the data. Prior to threading support, a relatively new feature, applications ip applications were just state engines, with socket I/O just one state, using select() or poll() to monitor state. These functions measured the leading edge event of a socket STREAM, data has arrived. If one did not read all the data received, select() (always), and poll() (most implementations) would not signal the socket handle ready until more data arrives. This is a common error in socket I/O applications.
My original point what that there exist no single socket interface method that removes the responsibility to manage the socket STREAMS like garbage collection has done for memory management. And, now we have learned, even garbage collectors do not completely remove the job of proper memory management, one can still obfuscate Object references in many ways that prevent Object memory reclamation.
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?
An MCB, or the memory control blocks defining the socket's mbufs within the ip stack application interface. It is a term I use, but is not part of any user level, or even stack level, data structures. I was incorrect to inject my nomenclature, but I have been working at low level IP for decades, developing many features for my old IPX used with such ease as Java's socket interfaces today.
Has that answered your question? .
- 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
- 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: Color of JComboBox
- Next by Date: re:Color of JComboBox
- 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
|