socket programming

Kevin X Lin klin at palsoccer.com
Wed Mar 21 23:46:54 CET 2001


Hi there, I have the following problem with socket programming:

I'm trying to setup a tcp client to talk to a tcp server sitting at a
certain port. When I issue :

mysocket.setblocking(1)
mysocket.send('something')
mysocket.recv(1024)

I was expecting I can receive all the data sent by server. Unfortunately,
this is not necessary the case. Sometimes I can't get all of data, worse,
the application protocal doesn't define end tag of the data, which prevent
me from doing a loop until I receive all data.

But if I do this:

mysocket.setblocking(1)
mysocket.send('something')
sleep(0.1)
mysocket.recv(1024)

I can get all data, yet I believe this is not a good solution which might
casusing other problems in the future.

Any suggestion?

Thanks.

Kevin







More information about the Python-list mailing list