Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
MSG_WAITALL and SO_RCVLOWAT
The usual behaviour of blocking recvfrom(2) is to
1) wait until the kernel buffer contains at least SO_RCVLOWAT(receive
low water) octets(default 1) or the socket is closed
2) copy the data from the kernel buffer to the userspace buffer,
possibly returning a short read even if the socket is not closed
MSG_WAITALL turns that into
1) wait until the kernel buffer contains a number of octets larger than
or equal to the size of the userspace buffer, or the socket is closed
2) copy the data from the kernel buffer to the userspace buffer; a short
read is returned only if the socket is closed
so MSG_WAITALL is like setting a per-read SO_RCVLOWAT. Usually the low
water threshold is 1 and the buffer size is larger. I don't know what
would happen is you set a large SO_RCVLOWAT then call recvfrom(2) with
MSG_WAITALL passing a userspace buffer smaller than SO_RCVLOWAT. Better
not to do that.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.