Board index » cppbuilder » Bug? TIdTCPServer does not change Defaultport at runtime

Bug? TIdTCPServer does not change Defaultport at runtime


2006-09-13 09:01:31 PM
cppbuilder32
Hi all,
with this code I try to change the defaultport property and it shows the desired port in the listbox, but allways the port set at designtime is active, there is no change to the new value.
Is this a bug? Or am I doing something wrong)
I use Indy 9 and BDS2006.
...
void __fastcall TForm1::Edit1DblClick(TObject *Sender)
{
IdTCPServer1->DefaultPort=StrToInt(Edit1->Text);
ListBox1->Items->Add( "Port set to: " +
IntToStr(IdTCPServer1->DefaultPort) );
}
...
Regards Robert
 
 

Re:Bug? TIdTCPServer does not change Defaultport at runtime

try setting the Active property to false, before changing the DefaultPort
and setting it back to true when done.
"RobertL" < XXXX@XXXXX.COM >wrote in message
Quote

Hi all,

with this code I try to change the defaultport property and it shows the
desired port in the listbox, but allways the port set at designtime is
active, there is no change to the new value.

Is this a bug? Or am I doing something wrong)

I use Indy 9 and BDS2006.

...
void __fastcall TForm1::Edit1DblClick(TObject *Sender)
{
IdTCPServer1->DefaultPort=StrToInt(Edit1->Text);
ListBox1->Items->Add( "Port set to: " +
IntToStr(IdTCPServer1->DefaultPort) );
}
...

Regards Robert
 

Re:Bug? TIdTCPServer does not change Defaultport at runtime

"RobertL" < XXXX@XXXXX.COM >wrote in message
Quote
with this code I try to change the defaultport property and it
shows the desired port in the listbox, but allways the port set
at designtime is active, there is no change to the new value.
Do you have any items already created in the Bindings collection when you
make the change? Changing the DefaultPort has no effect on existing items
in the Bindings collection, only on new items that are added to the
collection afterwards. Each Binding has its own Port property that it
listens on. That value is initialized by the DefaultPort only when the
Binding is first created. Changing the DefaultPort does not update the Port
of existing Bindings.
Gambit
 

{smallsort}

Re:Bug? TIdTCPServer does not change Defaultport at runtime

"Omar Zelaya" < XXXX@XXXXX.COM >wrote in message
Quote
try setting the Active property to false, before changing
the DefaultPort and setting it back to true when done.
That will not have any effect if there are already items in the Bindings
collection. If you set Active to false, you would have to also clear the
Bindings collection in order for the collection to use the new DefaultPort
value. Otherwise, you will have to loop through the collection itself
updating the Port property of the individual Binding items.
Gambit
 

Re:Bug? TIdTCPServer does not change Defaultport at runtime

Quote
Changing the DefaultPort does not update the Port
of existing Bindings.
hmm....
I didn't do anything with the binding collection. But what should I do when
I want to change the active port? Do I have to use another property or how
else can I update the port of an existing Binding ? Can you show me an
example?
Regards Robert
 

Re:Bug? TIdTCPServer does not change Defaultport at runtime

Thank you for your quick help Gambit,
in the meantime I found the way to clear the binding according to your tip:
...
void __fastcall TForm1::Edit1DblClick(TObject *Sender)
{
IdTCPServer1->Active=false;
IdTCPServer1->Bindings->Clear();
IdTCPServer1->DefaultPort=StrToInt(Edit1->Text);
IdTCPServer1->Active=true;
ListBox1->Items->Add( "Port: " + IntToStr(IdTCPServer1->DefaultPort) );
}
...
Regards Robert
"Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >schrieb im Newsbeitrag
Quote

"RobertL" < XXXX@XXXXX.COM >wrote in message
news:4508012b$ XXXX@XXXXX.COM ...

>with this code I try to change the defaultport property and it
>shows the desired port in the listbox, but allways the port set
>at designtime is active, there is no change to the new value.

Do you have any items already created in the Bindings collection when you
make the change? Changing the DefaultPort has no effect on existing items
in the Bindings collection, only on new items that are added to the
collection afterwards. Each Binding has its own Port property that it
listens on. That value is initialized by the DefaultPort only when the
Binding is first created. Changing the DefaultPort does not update the
Port
of existing Bindings.


Gambit


 

Re:Bug? TIdTCPServer does not change Defaultport at runtime

Thank you for your quick reply, Gambit.
I wrote a reply at the same evening from home, but it looks at it has got stuck in my providers newsserver, I can see it there, but not in the newsgroup accessed via Webinterface.
In the meantime, I could successfully change the active port.
According to our tip, I had a look at the BINDINGS and with insertion of a Clear() command it worked.
void __fastcall TForm1::Edit1DblClick(TObject *Sender)
{
IdTCPServer1->Active=false;
IdTCPServer1->DefaultPort=StrToInt(Edit1->Text);
IdTCPServer1->Bindings->Clear();
IdTCPServer1->Active=true;
ListBox1->Items->Add( "Port set to: " +
IntToSt(IdTCPServer1->DefaultPort) );
}
Regards Robert
 

Re:Bug? TIdTCPServer does not change Defaultport at runtime

I tried that already with no success.
Regards Robert