Amount of data that can be transfered between a client and a server.

Jason Orendorff jason at jorendorff.com
Sun Jan 6 13:08:50 EST 2002


> from socket import *
> import urllib, math, urlparse
> 
> s = socket(AF_INET, SOCK_STREAM)
> s.connect(("ncdm124.lac.uic.edu", 5040))
> 
> text = s.recv(10240)
> print text
> 
> 	
> text = s.recv(10240)
> print text
> 
> s.send("metadata expand"+"\n")
> 
> text = s.recv(10240)
> while 1:
>     print text
>     text = s.recv(10240)
> 
> It would be thankful if you can help me how to recive all the data and
> teriminate properly.

from socket import *

LIMIT = 16 * 1024

s = socket(AF_INET, SOCK_STREAM)
s.connect(("ncdm124.lac.uic.edu", 5040))

data = ''
while len(data) < LIMIT:
    chunk = s.recv(LIMIT - len(data))
    if chunk == '':
        break
    data += chunk

s.close()

print "read %d bytes of data:" % len(data)
print repr(data)

## Jason Orendorff    http://www.jorendorff.com/




More information about the Python-list mailing list