Advertisement
TLama

Untitled

Jun 19th, 2014
449
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 0.42 KB | None | 0 0
  1. function IsPortActive(const AHost: string; APort: Word): Boolean;
  2. var
  3.   IdTCPClient: TIdTCPClient;
  4. begin
  5.   Result := False;
  6.  
  7.   IdTCPClient := TIdTCPClient.Create(nil);
  8.   try
  9.     try
  10.       IdTCPClient.Host := AHost;
  11.       IdTCPClient.Port := APort;
  12.       IdTCPClient.Connect;
  13.       Result := True;
  14.     except
  15.       // ignore exceptions [really ? are you sure ?]
  16.     end;
  17.   finally
  18.     IdTCPClient.Free;
  19.   end;
  20. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement