kg@elan.elan.com (Ken Greer) (08/25/89)
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? I've searched all the documentation I have with no help. Ken Greer Elan Computer Group, Inc. 888 Villa St. 3rd Floor Mt View CA 94041 Phone: 415-964-2200 Internet: kg@elan.com UUCP: {ames,hplabs,uunet}!elan!kg
chris@mimsy.UUCP (Chris Torek) (08/27/89)
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
mitch@lynx.uucp (Mitch Bunnell) (08/29/89)
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 The packets are guaranteed to be atomic. You will only get a partial packet if your receive from buffer is too small. --------------- Mitch Bunnell - Lynx Real-time systems mitch@lynx. voice - (408) 370-2233 Robot: "They will never believe that it is the real amulet." Dr. Smith: "Of course they will. These naive aliens will believe anything."