sockets - recv with time out

Oleg Broytmann phd at phd.pp.ru
Fri Jan 11 03:12:44 EST 2002


On Thu, Jan 10, 2002 at 04:35:31AM -0800, sam wrote:
> I'm writing a Socket Server for an existing sockets client. Once a
> connection is opened up the client send me some data, and I reply. The
> client may then send more data (on the same connection) or may not. It
> is my responisbility to close the connection when the conversation is
> finished. At present I listen ad infinitum for more data, and my
> handler thread is blocked. I know generally this should be handled
> better, but seeing as am working with what I'm given is there a way I
> can do a recv with a timeout (to throw an exception, when the timeout
> is reached)? Is this something that can be achieved with non-blocking
> sockets and if so how?

   http://www.timo-tasi.org/python/timeoutsocket.py

Oleg.
-- 
     Oleg Broytmann            http://phd.pp.ru/            phd at phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.




More information about the Python-list mailing list