Receive data from socket stream

Irmen de Jong irmen.NOSPAM at xs4all.nl
Sat Apr 26 08:25:57 EDT 2008


s0suk3 at gmail.com wrote:
> Until now, I've been
> doing this little trick:
> 
> data = client.recv(256)
> new = data
> while len(new) == 256:
>     new = client.recv(256)
>     data += new

Are you aware that recv() will not always return the amount of bytes asked for?
(send() is similar; it doesn't guarantee that the full buffer you pass to it will be 
sent at once)

I suggest reading this: http://www.amk.ca/python/howto/sockets/sockets.html


--irmen



More information about the Python-list mailing list