Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Oct : Best method of keep-alive?
| Subject: | Best method of keep-alive? |
| Posted by: | "Jamie Dale" (j.da..@turboz.net) |
| Date: | Mon, 2 Oct 2006 18:50:43 |
Hi all
I was wondering if anyone has a idea or method for implementing a keep-alie
system using TIdTCPClient and TIdTCPServer?
I'm pretty familiar with the general theory - One end can send a 'ping' and
the other replies with a 'pong'.
My question is what is the best way to do this and how can one end of the
connection recognise if the time for the reply has expired?
One method I have been thinking of is
1) Server sends 'ping' with a serial number - IE Ping := 'ping:123';
2) Server adds serial into array.
3) Client responds with 'pong:123' so that the server recognises which ping
is being replied to. Server removes serial from array.
OR
Client does not respond. Timer kicks in and checks array for replies that
are outstanding and increments a count. Server then sends the same
ping/serial again.
4) On 3 failed replies the server disconnects the socket and calls the
OnDisconnect event to clear things up nicely.
How does this sound to you guys - And me ol pal Remy?