tcp socket programming
- From: Mohammed Smadi <smadim2@xxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 4 Oct 2005 13:21:56 -0400 (EDT)
hi;
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
code:
result = []
while True:
got=s.recv(1024)
print got
if not got: break
result.append(got)
got = [] # i tried also taking this out
s.close()
but this code just hangs in the loop and never quits
any ideas will be much appreciated
moe smadi
.
- Follow-Ups:
- Re: tcp socket programming
- From: Irmen de Jong
- Re: tcp socket programming
- Prev by Date: Re: "no variable or argument declarations are necessary."
- Next by Date: Re: Which SQL module to use?
- Previous by thread: how to debug when "Segmentation fault"
- Next by thread: Re: tcp socket programming
- Index(es):
Relevant Pages
|