SO_SNDLOWAT and write(2) return value

From: Muhammad Ali <M.ALI023_at_hotmail.com>
Date: Tue, 15 Nov 2022 03:42:18 UTC
Hi,
Consider the following scenario:

  1.  Socketpair(2) returns two connected sockets: sp[0] and sp[1]
  2.  Setsockopt(2) the option SO_SNDLOWAT for sp[1] to 10 bytes
  3.  Write(2) to sp[1] with exactly 10 bytes

Is it ever possible for write(2) to return less than 10 bytes in this case? Generally, I would think yes since setting SNDLOWAT only checks if there's enough buffer space for 10 bytes and if there is then we start writing, but the write may get interrupted and return 6 bytes, for example.

I have read APUE third edition page 624 and the man page for setsockopt(2) and it seems the two are conflicting or I am not understanding correctly. To quote APUE: "The minimum amount of data in bytes to transmit in a send call", see Page 624, Figure 16.21. As you can see this suggests that less than 10 bytes will never be returned but the FreeBSD setsockopt(2) man page suggests that less than 10 bytes can be returned.

Which is correct?

BTW, I don't think SAR meant the send(2) call (in the above quote) rather he just wrote send as a generic term to mean write/send/etc...