[DUG] TIdPeerThread.BeforeRun
Leigh Wanstead
leighw at softtech.co.nz
Tue Aug 7 10:13:50 NZST 2007
Good morning,
I am using indy 9.0.18 to in a tcp client/server application.
Here is the code which I have trouble in IdTCPServer.pas
procedure TIdPeerThread.BeforeRun;
begin
try
if Assigned(Connection.IOHandler) then begin
Connection.IOHandler.AfterAccept;
end
else begin
raise EIdTCPServerError.Create('');
end;
except
Terminate; //APR: was FreeOn Terminate := True; ?! It is ThreadMgr work
raise;
end;
if Assigned(Connection.Server.Intercept) then begin
Connection.Intercept := Connection.Server.Intercept.Accept(Connection);
end;
Connection.Server.DoConnect(Self); <--- The problem
// Stop this thread if we were disconnected
if not Connection.Connected then begin
Stop;
end;
end;
It is quite common to face Socket Error #10054 Connection reset by peer. I
can use normanl try except block on tcp client application to catch the
error and handle it. But what about tcp server?
If Connection.Server.DoConnect(Self); got Socket Error #10054, it will just
let indy routine to handle it. That is not I want. I want to handle this
error myself. How to catch it? Will event OnException of TIdTCPServer pass
the exception to my event handling delphi code?
I really don't want to modify indy code.
TIA
Regards
Leigh
More information about the Delphi
mailing list