Mark Tolonen <[EMAIL PROTECTED]> wrote: > > So every time I use I want to send some thing, I must use > > > > totalsent = 0 > > while sent < len(data): > > sent = sock.send(data[totalsent:]) > > totalsent += sent > > > > instead of a simple sock.send(data)? That's kind of nasty. Also, is it > > better then to use sockets as file objects? Maybe unbuffered? > > I think you meant: > > while totalsent < len(data): > > Python also has the sendall() function.
Just to elaborate, sendall does exactly the above for you. sendall(self, *args) sendall(data[, flags]) Send a data string to the socket. For the optional flags argument, see the Unix manual. This calls send() repeatedly until all data is sent. If an error occurs, it's impossible to tell how much data has been sent. There should really be a recvall for symmetry, but I don't think it would get much use! -- Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list