vern at icir.org
Fri Sep 21 00:12:22 PDT 2007
> So, when we call recv(), do we always have to read in 2048 bytes?
An individual call to recv() will read in *up to* the length of the buffer
you pass in (you specify the length in the third argument), but it may
return less if not a full buffer's worth of data was available.
> We can
> pass the number of message bytes in Send() by strlen(buffer), but there is
> no such call for recv() since we don't know if num_received = recv() is
> really the entire message. Correct?
Correct. The sender and receiver have to somehow coordinate in order for
the receiver to know when it has received an entire message from the sender.
How that coordination works is up to the application. For example, for
HTTP requests it's when the receiver sees a blank line (just a CRLF on a
line by itself) that it knows it has received the entire request.
More information about the ee122