Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!ncar!tank!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.unix.wizards Subject: Re: is RECVFROM atomic? Keywords: recv sockets Message-ID: <19279@mimsy.UUCP> Date: 26 Aug 89 19:15:37 GMT References: <615@elan.elan.com> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 18 In article <615@elan.elan.com> kg@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@mimsy.umd.edu Path: uunet!mimsy!chris