Article View: borland.public.cppbuilder.internet.socket
Article #5415Re: Close down connections from the server side. Indy.
From: Ulrik Nilsson
Date: Tue, 07 Sep 2004 07:25
Date: Tue, 07 Sep 2004 07:25
69 lines
3551 bytes
3551 bytes
"Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> wrote:
>
>"Ulrik Nilsson" <di2niul@chl.chalmers.se> wrote in message
>news:413cc343$1@newsgroups.borland.com...
>
>> while( ! AThread->Terminated && AThread->Connection->Connected() )
>
>You should not be looping like that. The OnExecute event is already looped
>for you. Get rid of the loop altogether.
>
>> AThread->Connection->Disconnect();
>
>Use DisconnectSocket() instead of Disconnect().
>
>> AThread->Connection->CheckForDisconnect();
>
>You don't need to call that. ReadLn() and WriteLn() will do that for you.
>
>> You wrote "Use the actual constructor instead". How and where?
>
>You do know what a constructor is in the first place, don't you? It is a
>class method that has the same name as the class itself. In this case,
>TForm1(), which is automatically generated for you by the IDE for VCL forms:
>
> __fastcall TForm1::TForm1(TComponent *Owner)
> : TForm(Owner)
> {
> // this is the constructor. Put your initialization code in here...
> }
>
>
>Gambit
>
>
Hi!
Thanks for the reply.
I've already tried to run the OnExecute method whitout a while(...) {...} loop with no luck. But thanks for the reason why.
As you guessed that didn't help me. Maybe I should have told you in the first place but I still get the "Terminate Thread Timeout" from the server application. At the moment I run
both the client and server application on the same machine.
Well, let's say that the code in the server application is correct. Then the problem must be in the client application. Is there any special "trick" you should do?
For example my close function looks like this:
void __fastcall TForm1::QUIT_ButtonClick(TObject *Sender)
{
if( TCPClient->Connected() )
{
TCPClient->WriteLn("QUIT");
lstMain->Items->Add( TCPClient->ReadLn() );
TCPClient->Disconnect();
}
else
lstMain->Items->Add("You're not connected...");
}
When I click on this button everything works fine. The threads close as I think they should and the OnDisconnet is fired on both sides.
I have also another question. Is it possible to debug the Indy sourcecode via some setting? I can't see a thing whats going on inside the functions call. It would be very useful...
Yes I do know what a constructor is. But, if you study the examples shipped with BCB6, they also use the OnCreate method to start the server.
Regards Ulrik
Technical Details
Message-ID:
<413d624f$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!news.tele.dk!news.tele.dk!small.news.tele.dk!npeer.de.kpn-eurorings.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<413cb130$1@newsgroups.borland.com> <413cbe74@newsgroups.borland.com> <413cc343$1@newsgroups.borland.com> <413cd762@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,94b92865a961b40 X-Google-Attributes: gid11508e,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Ulrik Nilsson" <di2niul@chl.chalmers.se> Sender: "Ulrik Nilsson" <di2niul@chl.chalmers.se> Reply-To: "Ulrik Nilsson" <di2niul@chl.chalmers.se> Subject: Re: Close down connections from the server side. Indy. Newsgroups: borland.public.cppbuilder.internet.socket X-User-Info: 213.114.98.47 References: <413cb130$1@newsgroups.borland.com> <413cbe74@newsgroups.borland.com> <413cc343$1@newsgroups.borland.com> <413cd762@newsgroups.borland.com> NNTP-Posting-Host: 207.105.83.66 Message-ID: <413d624f$1@newsgroups.borland.com> Date: 7 Sep 2004 00:25:03 -0700 X-Trace: newsgroups.borland.com 1094541903 207.105.83.66 (7 Sep 2004 00:25:03 -0700) Lines: 69 Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!news.tele.dk!news.tele.dk!small.news.tele.dk!npeer.de.kpn-eurorings.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail