When we call send() with an amount of data, send() first copies this data into an outgoing buffer provided by the operating system. If we call send() when its outgoing buffer is already full, it blocks until its buffer has emptied enough to accept more of our data.
In some cases where send() would block, it instead returns without copying all of the data as requested. In this case, the return value of send() indicates how many bytes were actually copied. One example of this is if your program is blocking on send() and then receives a signal from the operating system. In these cases, it is up to the caller to try again with any remaining data.
In this chapter's TCP server code section, we ignored the possibility that send() could block or be interrupted. In a fully robust application, what we need to do is compare the return value from send...