18 March 2019

## Socket Options

http://man7.org/linux/man-pages/man2/setsockopt.2.html

• Socket level options are in SOCKET(7).
• TCP specific options are in TCP(7).
• IP specific options are in IP(7).

SO_RCVLOWAT and SO_SNDLOWAT does not have an effect on blocking read/write. SO_RCVLOWAT and SO_SNDLOWAT apply to all non-blocking IO such as select, poll refer to UNIX Network Programming Volume 1, Third Edition: The Sockets Networking API.

• https://stackoverflow.com/a/45105711/431698
• https://my.oschina.net/yangan/blog/185262
• https://www.jianshu.com/p/d3442ff24ba6

https://news.ycombinator.com/item?id=13918141 says:

[1] Actually, EVFILT_READ and EVFILT_WRITE do support setting a low water mark, so you can theoretically condition readiness signaling on kernel buffer availability. But this is basically a kqueue-based extension to the traditional BSD Sockets API options SO_RCVLOWAT and SO_SNDLOWAT. You could theoretically get the same behavior on Linux, at least on a per socket basis (as opposed to the per event basis for kqueue) by setting those options. Alas, Linux doesn’t obey SO_RCVLOWAT or SO_SNDLOWAT when polling. :( Speculating, I bet it’s probably a performance optimization netting some single-digit performance improvement for the original expected use cases but, once again, keeping something difficult impossible.