Scatter/gather on sockets?

Anthony Greene sysfault at zetafunc.net
Sat Apr 1 15:21:45 EST 2006


On Sat, 01 Apr 2006 14:56:02 -0500, Roy Smith wrote:

> 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?

Is sendall() what you're looking for?

-- 
A wise man knows he knows nothing.




More information about the Python-list mailing list