Newsgroups : Borland : borland.public.delphi.internet.winsock : 2007 Apr : How to check for Disconnect on TIdTcpClient
| Subject: | How to check for Disconnect on TIdTcpClient |
| Posted by: | "Michael Stieler" (michael.stiel..@rie.eu) |
| Date: | Mon, 2 Apr 2007 14:15:14 |
Hi,
I have a general question.
I want to receive an event both if a .Disconnect; call succeded and also
if the connection is closed due to another reason, i.e. an error occured.
Is it right to do it like that?
procedure TModuleProxy.TcpStatus(ASender:TObject; const AStatus :
TIdStatus; const AStatusText : String);
begin
If AStatus = hsDisconnected then begin
if readThread<>nil then begin
readThread.Terminate;
readThread.WaitFor;
FreeAndNil(readThread);
end;
If Assigned(conn.IOHandler) then
conn.IOHandler.InputBuffer.Clear;
buffer := '';
// Fire event to main application
If Assigned(FOnDisconnect) then
FOnDisconnect(self);
end;
end;
I'm asking because my apps seems to have a problem if a Disconnected
Status is Received shortly after I connected.
Thanks,
Michael