tcp socket programming

Mohammed Smadi smadim2 at
Tue Oct 4 19:21:56 CEST 2005

If i have a tcp connection with a remote server, what is a good way to 
read all the data into a buffer before starting to process the data?
I know that the data recieved will be 3 lines with CRLF between them.  
However if I can sock.recv(1024) the output is not consistent all the 
time, sometime i get one line and sometimes i get two.  So I figures I 
should read all the data first then work on it and I used the following 
result = []
while True:
    print got
    if not got: break
    got = [] # i tried also taking this out

but this code just hangs in the loop and never quits

any ideas will be much appreciated

moe smadi

More information about the Python-list mailing list