Re: non blocking sockets and alternatives




"EJP" <esmond.not.pitt@xxxxxxxxxxxxxxx> wrote in message
news:MkGwl.29741$cu.3965@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
it seems Java structures the stream
between client and server by doing the following:
size_of_data + the_data

Nope. It just sends the data you sent. Sometimes *applications* prepend a
size word to a transaction, so you know when you've read it all.

A mistake TCP novices frequently make is to think that the data blocks they
write are preserved as blocks to be read. Unfortunately, small byte arrays
on loopback or local LAN will reinforce this illusion. In reality, however,
the stream truly has no boundaries between what is written and what is read.
The network is free to concatenate and break up the stream as it sees fit,
so long as it preserves the underlying byte sequence. The main techniques
for identifying application-specific chunks are:
Send a fixed-length byte count and then the data
Use a particular byte (e.g. 0, \r, \r\n, etc) as a terminator
Use fixed-length messages.
Use one message per connection

When reading, assume the data will arrive in fragments and readFully until
you have it all.

Matt Humphrey http://www.iviz.com/


.



Relevant Pages

  • Re: minor flaws in handling of streams and tunneling
    ... If you add this stream by entering a comment in the properties of the ... NTFS Tunneling preserves the date values of files when you replace ... In addition you can disable Tunneling by setting ... delete file Z from folder F ...
    (microsoft.public.win32.programmer.kernel)
  • NTFS: minor flaws in handling of streams and tunneling
    ... In NTFS every file can have streams. ... If you add this stream by entering a comment in the properties of the ... NTFS Tunneling preserves the date values of files when you replace ... delete file Z from folder F ...
    (microsoft.public.win32.programmer.kernel)