Sockets: data black holes.
Sometimes, the opacity of the BSD socket interface is a real pain in the backside.
For example, what happens if you do the following:
/* Set a 4k outgoing buffer size */ int bufSize = 8*1024 ; setsockopt(socket, SOL_SOCKET, SO_SNDBUF, &bufSize, sizeof(int)) ; /* Send 8k of data to a host we know will only receive 2k for a while */ retval = send(socket, buffer, bufSize) ; /* Data is now in the send buffer, but the remote host only has buffers for 2k, so 6k of our buffer is "hot" */ int shortSize = 2*1024 ; int retval = setsockopt(socket, SOL_SOCKET, SO_SNDBUF, &shortSize, sizeof(int)) ; /* Did we just truncate the outgoing send buffer? Or will this generate an error */
Categories: Coding
networking, sockets

You found some old code of Ronald kicking around?
Admittedly FWIR there’s a few free() calls missing :)
Interesting!
If I had to pick from your two options, I’d say “generate an error”, but it might also block until the send buffer can be truncated without loss of data.
higgs boson?
As far as I can tell, under Linux, it doesn’t generate an error and it certainly doesn’t block…
What it appears to do is truncate the stream…
For a TCP socket, it would also be technically valid to truncate the buffer as long as all following send()s on the socket fail :)