Newsgroups : Borland : borland.public.delphi.internet.winsock : 2007 Mar : Re: How to set the listen port for the TIdTCPServer?
| Subject: | Re: How to set the listen port for the TIdTCPServer? |
| Posted by: | "Remy Lebeau (TeamB)" (no.spam@no.spam.com) |
| Date: | Sun, 25 Mar 2007 15:17:56 |
"Bo Berglund" <bo.berglund@telia.com> wrote in message
news:08kd035hgedr2psi3q999duppe00vo8gcm@4ax.com...
> If I call SetStatusPort with the value 6001 and then call Openserver
> and then look in a command window with
> netstat -a -p tcp
> the result is that I can't see the port 6001 listed as a listening
> port. Why?
Are there any entries already in the TIdTCPServer.Bindings collection
before you call SetStatusPort()? Setting the DefaultPort only effects
new entries that are added to the Bindings afterwards. It has no
effect on entries that already exist in the collection. So if you do
have existing entries, then you will need to loop through them setting
their Port property individually, ie:
procedure TToolComm.SetStatusPort(const Value: word);
var
I: Integer;
begin
FStatusPort := Value;
FsrvCommand.DefaultPort := Value;
for I := 0 to FsrvCommand.Bindings.Count-1 do
FsrvCommand.Bindings[I].Port := FsrvCommand.DefaultPort;
FsrvStatus.DefaultPort := Value + 1;
for I := 0 to FsrvStatus.Bindings.Count-1 do
FsrvStatus..Bindings[I].Port := FsrvStatus.DefaultPort;
end;
Gambit