Menu

#4 recvmsg --nonblocking relies on nonportable MSG_DONTWAIT option

0.2
open
Tetsujin
None
2017-07-08
2017-07-08
Tetsujin
No

Normally to be sure that read() and recvmsg() calls return immediately the socket itself must be set to a non-blocking mode with the O_NONBLOCK option. Starting in version 2.2, Linux provides the MSG_DONTWAIT option which can be used to make a single recv() or recvmsg() call non-blocking without changing the state of the socket. MSG_DONTWAIT is provided on current versions of BSD and Linux, but it is not part of POSIX and some versions of Unix will not support the flag.

The mode could be simulated by using a call like select() or poll() to check for available data prior to attempting to read data from the socket. This approach could fail due to race conditions if multiple processes or threads are trying to read from the socket, but generally speaking it is probably good enough for platforms that don't support MSG_DONTWAIT.

Acceptance Criteria
"recvmsg --nonblocking" mode should work correctly on systems that lack MSG_DONTWAIT

Discussion


Log in to post a comment.