Socket stream
David Bolen
db3l at fitlinxx.com
Tue Feb 26 19:15:07 EST 2002
More information about the Python-list mailing list
Tue Feb 26 19:15:07 EST 2002
- Previous message (by thread): Socket stream
- Next message (by thread): Anagram
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Christian Maus <maus at netz.klinik.uni-mainz.de> writes: > Hello, > > I try to control a device via a com server. Setting a command to the device > works fine, but when I try to read the answer, my loop for reading from the > socket does not terminate. My loop looks like this: > > while 1: > data = sockobj.recv(1024) > if not data: break > print data > sockobj.close() > > I get the output: (...) > and then I'm stuck in the loop. Any idea what the problem is? If there is no data on the socket and you issue a recv() it will block until data arrives. I don't know your device protocol but you don't seem to have a termination condition in your loop. You probably want to detect when the device has completed sending you information and exit the loop on that condition, rather than looking for an empty string (which should only happen when the other end closes down the socket). -- -- David -- /-----------------------------------------------------------------------\ \ David Bolen \ E-mail: db3l at fitlinxx.com / | FitLinxx, Inc. \ Phone: (203) 708-5192 | / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ \-----------------------------------------------------------------------/
- Previous message (by thread): Socket stream
- Next message (by thread): Anagram
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list