recv

Jon Ribbens jon+usenet at unequivocal.co.uk
Wed Jun 18 04:49:44 EDT 2003


In article <3EF02537.7050609 at uni-koblenz.de>, Oleg Seifert wrote:
> def read():
>      print s.recv(1024)
> 
> How can I print the whole response, independent of the structure
> (numer of lines) of the response?

You need to keep calling recv repeatedly to get the whole response.
recv(1024) doesn't mean "give me 1024 bytes", it means "don't give me
more than 1024 bytes".

def read():
  while 1:
    r = s.recv(1024)
    if not r: break
    sys.stdout.write(r)
  sys.stdout.write("\n")




More information about the Python-list mailing list