Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Find Open Port

Avatar of aceswildab1
aceswildab1 asked on
ProgrammingDelphi
12 Comments1 Solution1765 ViewsLast Modified:
I'm trying to search for an open port using Delphi. Basically, I have a port range that I am trying to scan over. If the port is closed (or unable to be connected with), it moves onto the next. Problem is that no ports are showing as being open (if the first is closed, all others are saying they are closed). Any suggestions on what I'm doing wrong? Here is the code I'm using:

  for intIndex := qryServer.FieldByName('port_min').AsInteger to qryServer.fieldByName('port_max').AsInteger do
    begin
      if ServerConnect(idyServer, intIndex, idyFreeze)= TRUE then
        break;
    end;

function ServerConnect(AServer : TIdTCPServer; APort : Integer; AFreeze : TIdAntiFreeze) : Boolean;
begin
  try
    AServer.DefaultPort := APort;
    AFreeze.Active := TRUE;
    AServer.Active := TRUE;

    Application.ProcessMessages;

    Result := TRUE;
  except
    Result := FALSE;
  end;
end;
ASKER CERTIFIED SOLUTION
Avatar of aflarin
Commented:
This problem has been solved!
Unlock 1 Answer and 12 Comments.
See Answers