In POSIX C we can use writev to write multiple arrays at once to a file descriptor. This is useful when you have to concatenate multiple buffers in order to form a single message to send through a socket (think of a HTTP header and body, for instance). This way I don’t need to call send twice, once for the header and once for the body (what prevent the messages to be split in different frames on the wire), nor I need to concatenate the buffers before sending.
My question is, is there a Python equivalent?
There is in the upcoming Python 3.3, now in alpha testing. See
socket.sendmsg.