[Tutor] sockets

Danny Yoo dyoo@hkn.eecs.berkeley.edu
Mon, 2 Jul 2001 16:34:59 -0700 (PDT)


On Tue, 3 Jul 2001, Brendon wrote:

> 
> s.send(loginData)
> data = s.recv(1024)
> 
> s.close()
> print 'Received', data
> #-------------------------

> the statement "data = s.recv(1024)" apparently causes the first 1024
> characters to be assigned to 'data', but because eventually it'll go
> over the limit i want it to write every packet to a file which can be
> queried later.

You can do the s.recv() in a loop that keeps on pulling data from the
socket, until the socket runs dry.

###
whole_data = ''
while 1:
    data = s.recv(1024)
    if not data: break
    whole_data += data
###

Hope this helps!