Detecting unexpectedly closed sockets

Alex Tweedly alex at
Sat Oct 16 19:27:37 EDT 2004

At 21:24 16/10/2004 +0200, Tomas Franzén wrote:

>Dar, Xavier, Björnke,
>Thanks for your suggestions.
>I will let the server send a ping command to the client, and let the 
>client respond.
>When the server hasn't received a ping for a while, it considers the 
>client gone, and vice versa.

If it were me, I'd make the client send the "ping" and the server respond. 
It's equally effective for keeping track of connections, and keeps the 
"sense" of initiation and reaction right (for my way of thinking of 

And I'd be traditional, and set it up so the keep-alives should happen 
every N seconds - and the server only assumes loss of connection if 3 * N 
seconds have elapsed since the last ping was received. You might even allow 
clients to have different keep-alive timer values (various reasons why you 
might want that), and then they should pass their timer value to the 
server, so it can use the appropriate time-out logic. (And possibly thereby 
avoid a potential future bug if you need to change the time-out value and 
operator error leads to it being configured differently between the two ends).

-- Alex.

More information about the Use-livecode mailing list