Article View: borland.public.cppbuilder.internet.socket
Article #5412Re: Close down connections from the server side. Indy.
From: Ulrik Nilsson
Date: Mon, 06 Sep 2004 20:06
Date: Mon, 06 Sep 2004 20:06
62 lines
2824 bytes
2824 bytes
"Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> wrote:
>
>"Ulrik Nilsson" <di2niul@chl.chalmers.se> wrote in message
>news:413cb130$1@newsgroups.borland.com...
>
>> void __fastcall TForm1::FormCreate(TObject *Sender)
>
>Do not use the OnCreate event in C++. It is a Delphi remnant that does not
>work properly in C++ as it can be triggered before the constructor, which is
>illegal in C++. Use the actual constructor instead.
>
>> The problem is that my program stops at one of the above
>> lines. It doesn't matter which I use when I click the "Close"
>> button. And, of course, no OnDisconnect is fired in the client.
>
>Please show all of your OnExecute code. You are probably blocking the peer
>thread from shutting down properly.
>
>
>Gambit
>
Hi Gambit!
Thanks for the fast reply. The current OnExecute code is this:
void __fastcall TForm1::TCPServerExecute(TIdPeerThread *AThread)
{
while( ! AThread->Terminated && AThread->Connection->Connected() )
{
AnsiString str = AThread->Connection->ReadLn("\n", 2000, 10);
//AnsiString str = AThread->Connection->ReadLn();
if( str == "HELLO" )
AThread->Connection->WriteLn("Welcome here...");
else if( str == "QUIT" )
{
AThread->Connection->WriteLn("OK");
AThread->Connection->Disconnect();
}
else if( str == "MYIPADR" )
{
AnsiString IP = AThread->Connection->Socket->Binding->PeerIP;
AnsiString Port = IntToStr( AThread->Connection->Socket->Binding->PeerPort );
AnsiString str = "Your IP-Address is: " + IP + " and portnumber is: " + Port;
AThread->Connection->WriteLn( str );
}
else
AThread->Connection->CheckForDisconnect();
}
}
You wrote "Use the actual constructor instead". How and where?
Regards Ulrik
>
Technical Details
Message-ID:
<413cc343$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!fr.ip.ndsoftware.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>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> NNTP-Posting-Host: 207.105.83.66 Message-ID: <413cc343$1@newsgroups.borland.com> Date: 6 Sep 2004 13:06:27 -0700 X-Trace: newsgroups.borland.com 1094501187 207.105.83.66 (6 Sep 2004 13:06:27 -0700) Lines: 63 Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!fr.ip.ndsoftware.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail