How to set the listen port for the TIdTCPServer?

Giganews Newsgroups
Subject: How to set the listen port for the TIdTCPServer?
Posted by:  Bo Berglund (bo.berglu…@telia.com)
Date: Sun, 25 Mar 2007

I have tried tp create a handler object for communications with a
machine tool (discussed in another thread).
This object has two TIdTCPServer objects created in its constructor.
I want to set the listen ports for these objects to some value via a
property of my communications object, so I have a SetPort procedure
connected to the write of that property.
Here is the code of that part:

procedure TToolComm.SetStatusPort(const Value: word);
begin
  FStatusPort := Value;
  FsrvCommand.DefaultPort := Value;
  FsrvStatus.DefaultPort := Value + 1;
end;

Then I later open up the listening with this command:

function TToolComm.OpenServer: boolean;
begin
  if not FsrvCommand.Active then
    FsrvCommand.Active := true;
  Result := FsrvCommand.Active;
end;

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?

What am I doing wrong here???

Replies