Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Aug : Re: How to exit gracefully on listener thread when server crashes.
| Subject: | Re: How to exit gracefully on listener thread when server crashes. |
| Posted by: | "Gerhard Venter" (ieatspam4breakfast@spam.com) |
| Date: | Fri, 18 Aug 2006 12:04:34 |
"Remy Lebeau (TeamB)" <no.spam@no.spam.com> wrote in message
news:44e60064$1@newsgroups.borland.com...
> If possible, implement a keep alive in your protocol. Have the client
> send
> a keep alive packet to the server periodically. If the server does not
> respond in a timely manner, then the client disconnect from the server.
> This also allows the server to disconnect dead clients that do not send
> data
> for awhile if they crashed.
>
Do you think it would be a good idea to send the keepalive packet after the
readtimeout occured? As I understand it the Run thread reads for 5000ms gets
out and gets back into a read again for 5000ms.
> Get rid of the loop altogether, and get rid of the checks for a
> disconnect.
> Run() is already looped by TIdThread, and ReadLn() already handles
> disconnect detection. An uncaught socket exception during reading/writing
> will escape back into TIdThread and allow it to terminate itself
> gracefully.
>
Thanks Gambit it works like a charm now!