A lot of beginning (and not-so-beginning!) TCP/IP developers see send() and recv(), and assume they will have
a 1 to 1 correspondence.
In fact, they usually will, but they are not guaranteed to. This makes the false assumption more prevalent.
TCP reserves the right to aggregate multiple smaller packets into fewer larger packets, or split large packets into a greater
number of smaller packets. And this is reflected in the send()/recv() in C code, or Python code. This is because TCP is
a byte-oriented protocol, not a message-oriented protocol.
The practical upshot is, if you write your code assuming a 1:1 relationship between
send() and recv(), your application will most likely work most of the time, but suffer
from seemingly strange failures now and then.
you should make sure your messages have a
well-defined structure, with terminator characters
(\n or \0, for example) or lengths (ASCII or network
order int's, for example) or whatever. \n has the
advantage of making it so you can do manual testing
via telnet or netcat
restart your system calls as needed:
C: put for loops around all your EINTR-capable system
calls, plus check and act on return values.
In some cases a length will be returned, and it
won't necessarily be the length you originally
requested