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 */