Scatter/gather Socket Write In Python
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 t
Solution 1:
There is in the upcoming Python 3.3, now in alpha testing. See socket.sendmsg
.
Solution 2:
Python supports
os.writev()
as well assendmsg()
. These functions are atomic, so are equivalent of callingwrite()
andsend()
respectively with concatenated buffer.There is
TCP_CORK
. You may say kernel not to send partial frames until un-corked.
Using either technique, you may have control over partial TCP frames.
Post a Comment for "Scatter/gather Socket Write In Python"