newbie question

Krzysztof Stachlewski stach at fr.pl
Fri Apr 16 02:35:03 EDT 2004


"jeff" <plastic"no-spam-pls"@xsintrk.net> wrote in message
news:Xns94CCAEBD1A18Eplasticnospamplsxsin at 216.77.188.18...

> i only want the socket to close if the word 'kill' has been sent.
> i just tried 'if sdata == "kill\r\n": s.close()', kill\r\n was the string
> repr(sdata) returned.  the IF statement works, but i'm getting a 'bad file
> descriptor' error on the s.close().

This is because you are trying to use a socket that is already closed.
You are calling s.close() but you are not break-ing out of the loop.
In the next iteration s.recv() is called, but s is closed
at that moment. Add a break after the call to s.close().

Stach




More information about the Python-list mailing list