is RECVFROM atomic?

Chris Torek chris at mimsy.UUCP
Sun Aug 27 05:15:37 AEST 1989


In article <615 at elan.elan.com> kg at elan.elan.com (Ken Greer) writes:
>Are packets received by recvfrom atomic?  That is, if I request 256
>bytes will I ever get less?  If I set non-blocking (NDELAY) mode,
>I can recieve 0 bytes, but can I receive a partial packet?

When recvfrom() is receiving a datagram (more precisely, when it is
reading a socket whose protocol claims to be atomic), it will always
return either the whole datagram, or as much as will fit in your
buffer, the rest being discarded.

If you ask for 256 bytes, and the next datagram is 12 bytes long,
you will get 12 bytes back.  If the next datagram is 512 bytes, you
will get 256 and the other 256 will fall into the bit bucket.

This is true for 4BSD, at least.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris at mimsy.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.unix.wizards mailing list