SethCoast
SethCoast

Reputation: 349

What happens when you call read() with length that is too large?

What happens when you call read() (or recv()) on an open socket, and you specify a length that is more the number of bytes ready to be read in the buffer (TCP) or the length of the next datagram (UDP)?

Upvotes: 1

Views: 218

Answers (1)

dbush
dbush

Reputation: 224842

In both cases, if the size of the buffer is larger than the amount of available data, what data is available is read and the number of bytes actually read are returned from the function. That return value is what you should use when operating on the data.

Upvotes: 4

Related Questions