Newsgroups : Borland : borland.public.delphi.internet.winsock : 2007 Apr : TCPServer OnDisconnect won't trigger on lost connection
| Subject: | TCPServer OnDisconnect won't trigger on lost connection |
| Posted by: | "Pera Detlic" (branislav..@yahoo.co.uk) |
| Date: | Mon, 23 Apr 2007 00:09:56 |
Hi,
I wrote a myServer and myClient applications and everything is working just
fine.
When Client is connected I send and receive data.
When I disconnect Client, Server remove thread in all cases.
But if I disconnect NET/LAN cable from Client PC, then Server continue to
work like there is no problem, but there is.
How to detect that kind of Client disconnection ?
My code is (indy 10) :
procedure TFormF.TCPServerDisconnect(AContext: TIdContext);
var Client: PClient;
begin
Client := PClient(AContext.Data);
try
Clients.LockList.Remove(Client);
finally
Clients.UnlockList;
end;
FreeMem(Client);
AContext.Data := nil;
end;