|Subject:||Re: Indy 9.0 Delphi 7 and TCPclient disconnect problem|
|Posted by:||Remy Lebeau (TeamB) (firstname.lastname@example.org)|
|Date:||Wed, 31 May 2006|
"Grobi" <grobi…@gmx.net> wrote in message
> On Disconnect I terminate the thread
That is the wrong thing to do. Indy is not an event-driven library. If the
server closes the connection, OnDisconnect will not be triggered. It is
only triggered when Disconnect() is explicitally called. What you should be
doing instead is to just keep reading and then terminate the thread when the
ReadLn() throws an exception because of the disconnect. Have a look at the
source code for TIdTelnet for an example of a threaded client.
> ( while not Thread.terminated do begin
> Thread.terminate;application.processmessages;end; )
You should be using the thread's WaitFor() method instead of looping
> but than the execute
> method of the thread crashes with an accessviolation while it tries to
> execute the TCPClient.readln function.
It will not throw an AV. But it very likely (and should) be throwing a
socket exception instead. That is perfectly normal behavior for Indy.
Indy 9.0 Delphi 7 and TCPclient disconnect problem posted by Grobi on Thu, 1 Jun 2006