Scatter/gather on sockets?

Roy Smith roy at panix.com
Sat Apr 1 14:56:02 EST 2006


I've got a bunch of strings in a list:

vector = []
vector.append ("foo")
vector.append ("bar")
vector.append ("baz")

I want to send all of them out a socket in a single send() call, so
they end up in a single packet (assuming the MTU is large enough).  I
can do:

mySocket.send ("".join (vector))

but that involves creating an intermediate string.  Is there a more
efficient way, that doesn't involve that extra data copy?



More information about the Python-list mailing list