[DUG] TIdPeerThread.BeforeRun
Leigh Wanstead
leighw at softtech.co.nz
Tue Aug 7 13:47:45 NZST 2007
I have solved the issue.
TMyIdPeerThread = class(TIdPeerThread)
protected
procedure BeforeRun; override;
end;
In startup routine
IdTCPServerMain.ThreadClass := TMyIdPeerThread;
In TMyIdPeerThread.BeforeRun do my own exception handling logic ;-)
Regards
Leigh
www.smootharm.com
-----Original Message-----
From: delphi-bounces at delphi.org.nz
[mailto:delphi-bounces at delphi.org.nz]On Behalf Of Leigh Wanstead
Sent: Tuesday, August 07, 2007 11:10 AM
To: delphi at moorhouse.net.nz; NZ Borland Developers Group - Delphi List
Subject: RE: [DUG] TIdPeerThread.BeforeRun
Hi David,
Thanks
Regards
Leigh
-----Original Message-----
From: delphi-bounces at delphi.org.nz
[mailto:delphi-bounces at delphi.org.nz]On Behalf Of David Moorhouse
Sent: Tuesday, August 07, 2007 10:50 AM
To: NZ Borland Developers Group - Delphi List
Subject: Re: [DUG] TIdPeerThread.BeforeRun
Hi Leigh
Post this one to the Indy NG.
Remy will have you sorted in short order.
Cheers
D
On Tue, 7 Aug 2007 10:13:50 +1200, you wrote:
>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
>
>
>_______________________________________________
>NZ Borland Developers Group - Delphi mailing list
>Post: delphi at delphi.org.nz
>Admin: http://delphi.org.nz/mailman/listinfo/delphi
>Unsubscribe: send an email to delphi-request at delphi.org.nz with Subject:
unsubscribe
_______________________________________________
NZ Borland Developers Group - Delphi mailing list
Post: delphi at delphi.org.nz
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to delphi-request at delphi.org.nz with Subject:
unsubscribe
_______________________________________________
NZ Borland Developers Group - Delphi mailing list
Post: delphi at delphi.org.nz
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to delphi-request at delphi.org.nz with Subject:
unsubscribe
More information about the Delphi
mailing list