Link to home
Start Free TrialLog in
Avatar of twineMAN
twineMAN

asked on

hook a port

how can I detect when a port (winsock) is used and depending of situation close the port.
Avatar of Epsylon
Epsylon

You can detect if the port is available by opening it yourself. If it fails the port is in use.

It is impossible to close a port that is being used by another program.

Epsylon.
Put a ServerSocket on your form and try this code:

  ServerSocket1.Port := yourport;
  try
    ServerSocket1.Active := true;
  except
    ShowMessage('Port is in use');
  end;

Epsylon.
that's it, i think...
Well, since twineMAN is not responding.....
ASKER CERTIFIED SOLUTION
Avatar of Epsylon
Epsylon

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial