Scatter/gather on sockets?

Roy Smith roy at panix.com
Sat Apr 1 17:29:39 EST 2006


In article <pan.2006.04.01.20.21.40.634232 at zetafunc.net>,
 Anthony Greene <sysfault at zetafunc.net> wrote:

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

No.  Sendall() is actually what I'm using now.  It handles the other side 
of the issue; issuing repeated send() calls if the system fragments your 
buffer.  I'm trying to aggregate lots of small buffers into one large one.



More information about the Python-list mailing list