heartbeats

Sybren Stuvel sybrenUSE at YOURthirdtower.com.imagination
Fri Dec 9 10:50:49 EST 2005


Yves Glodt enlightened us with:
> In detail I need a daemon on my central server which e.g. which in a
> loop pings (not really ping but you know what I mean) each 20
> seconds one of the clients.

You probably mean "really a ping, just not an ICMP echo request".

> The only thing the client has to do is to accept the connection.
> (optionally sending back some bytes). If it refuses it is assumed to
> be offline.

Ok, fair enough.

> My central server, and this is important, should have a short
> timeout.  If one client does not respond because it's offline, after
> max. 10 seconds the central server should continue with the next
> client.

I'd write a single function that pings a client and waits for a
response/timeout. It then should return True if the client is online,
and False if it is offline. You can then use a list of clients and the
filter() function, to retrieve a list of online clients.

Sybren
-- 
The problem with the world is stupidity. Not saying there should be a
capital punishment for stupidity, but why don't we just take the
safety labels off of everything and let the problem solve itself? 
                                             Frank Zappa



More information about the Python-list mailing list