[ee122] UDP's recvfrom() abstraction

vern at cs.berkeley.edu vern at cs.berkeley.edu
Wed Nov 21 10:26:14 PST 2007


> So my question is
> this: if the sender sends us two distinct UDP packets like this:
> "hi how", "are you doing your ee122 project"
> and we call recvfrom() asking for something like 100 bytes, could we
> get this: "hi how are you doing your ee122 project" or maybe "hi how"
> or maybe just "hi"?

No.  You'll receive them as distinct packets, assuming they haven't been
lost.  They might arrive out of order, however.

> This same question applies to the sender side as well. Will two calls
> to UDP's sendto() always result in two UDP packets?

Yes, if by UDP's sendto() you mean sendto() using a socket of type SOCK_DGRAM.

> So, if I want to send the
> message "hi how are you ", and I call sendto() with this buffer, but
> sendto() returns 3

It won't for SOCK_DGRAM.

		Vern


More information about the ee122 mailing list