newbie problem: use socke lib to retrieve one web page:

read-the-signature at read-the-signature at
Thu Sep 5 07:20:45 EDT 2002

koko <kokohh at> wrote:
> I write this to retrieve one web page using socket lib.
> [snip: code]
> s.connect((HOST,PORT))
> s.send(m)
> data=s.recv(4096)
> print data
> s.close()
> -----------
> But I retrieved nothing and the program stuck.

Your code probably is _too quick_ for the server. That is, you tried to
read data while the server was still busy processing. You could "sleep" a
little, before reading. Oh yeah, are you sure that 

    data = s.recv(4096)

will _always_ give you all of the data? You might want to take a look at
asyncore [1] which provides a nicer way to handle these situations. I'm not
sure, but I expect that the Python cookbook [2] also has some interesting
things to say about this topic.

    Good luck!



b a s {dot} v a n g i l s {at} c s {dot} k u n {dot} n l
BOFH excuse #63:
not properly grounded, please bury computer

More information about the Python-list mailing list