Thread View: borland.public.cppbuilder.internet.socket
3 messages
3 total messages
Started by Vladimir Stefanovic
Thu, 24 Nov 2005 15:47
About changing DefaultPort on TIdTCPServer...
Author: 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
Re: About changing DefaultPort on TIdTCPServer...
Author: Remy Lebeau (TeamB)
Date: Fri, 25 Nov 2005 06:41
Date: Fri, 25 Nov 2005 06:41
35 lines
2350 bytes
2350 bytes
"Vladimir Stefanovic" <antivari@po.sbb.co.yu> wrote in message
news:4385e08a@newsgroups.borland.com...
> 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?
Changing the DefaultPort property has no effect at all on existing entries
in the TIdTCPServer's Bindings collection. In order to change the port that
they are listening on, you need to either:
1) clear the Bindings collection and then re-add the desired entries to it
before activating the server. New entries added to the collection will pick
up the current DefaultPort value:
IdTCPServer->Active = false;
IdTCPServer->DefaultPort = StrToInt(CONFIG_PORT);
IdTCPServer->Bindings->Clear();
for(int x = 0; x < NumberOfDesiredBindings; ++x)
IdTCPServer->Bindings->Add()->IP = "whatever";
IdTCPServer->Active = true;
2) loop through the existing entries in the Bindings collection changing
their Port properties individually:
int NewPort = StrToInt(CONFIG_PORT);
IdTCPServer->Active = false;
for(int x = 0; x < IdTCPServer->Bindings->Count; ++x)
IdTCPServer->Bindings->Items[x]->Port = NewPort;
IdTCPServer->Active = true;
Gambit
Re: About changing DefaultPort on TIdTCPServer...
Author: Vladimir Stefanovic
Date: Tue, 29 Nov 2005 05:16
Date: Tue, 29 Nov 2005 05:16
7 lines
1115 bytes
1115 bytes
Thank you... this work! -- Best regards, Vladimir Stefanovic
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads