Article View: borland.public.cppbuilder.internet.socket
Article #3028About changing DefaultPort on TIdTCPServer...
From: Vladimir Stefanovic
Date: Thu, 24 Nov 2005 15:47
Date: Thu, 24 Nov 2005 15:47
61 lines
2702 bytes
2702 bytes
Hi,
I made a simple server (Service App + TIdTCPServer),
and I wanted to implement changing some server params
on fly. Unfortunately, that doesn't work... and I cannot
realize why:
(Indy9)
void __fastcall TTicketService::ServiceExecute(TService *Sender)
{
// ...
while ( !Terminated )
{
// do not even try to change something if...
// ... a TCP task is in progress (ie, a connection is active)...
if ( !TaskInProgress )
{
// if service app is notifed (DoCustomControl)...
// ...that it should update config ...
if ( ReloadRequest )
{
// back to default state
ReloadRequest = false;
// LOG just for the purpose of this test: written OLD value
GoSendMessageToLog( CONFIG_PORT );
// This reads the INI file and sets CONFIG_PORT to new value
ReloadIniToFastConfig();
// LOG just for the purpose of this test: written (really) NEW
value
GoSendMessageToLog( CONFIG_PORT );
// PROBLEM:
// After next three commands the server continued to...
// ... *function* but with *old* value!!! My clients...
// still could connect by the *old* Port value, and not the new
one!
// WHY?
IdTCPServer->Active = false;
IdTCPServer->DefaultPort = StrToInt( CONFIG_PORT );
IdTCPServer->Active = true;
// Message to LOG
GoSendMessageToLog( "Configuration reloaded." );
}
}
Sleep ( 500 );
ServiceThread->ProcessRequests( false );
}
}
--
Best regards,
Vladimir Stefanovic
Technical Details
Message-ID:
<4385e08a@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx02.iad01.newshosting.com!newshosting.com!news-out.newsfeeds.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 11508e,1582af998fda5c7c,start X-Google-Attributes: gid11508e,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Vladimir Stefanovic" <antivari@po.sbb.co.yu> Newsgroups: borland.public.cppbuilder.internet.socket Subject: About changing DefaultPort on TIdTCPServer... Date: Thu, 24 Nov 2005 16:47:52 +0100 Lines: 63 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-RFC2646: Format=Flowed; Original NNTP-Posting-Host: 82.117.212.65 Message-ID: <4385e08a@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1132847242 82.117.212.65 (24 Nov 2005 07:47:22 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx02.iad01.newshosting.com!newshosting.com!news-out.newsfeeds.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail