Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function CheckURLConnection(Host: String; Port: integer=80; Timeout: integer=1000): boolean;
- var TCP: TIdTCPClient;
- begin
- TCP:=TIdTCPClient.Create(nil);
- try
- TCP.Host:=Host;
- TCP.Port:=Port;
- TCP.ConnectTimeout:=Timeout;
- try
- TCP.Connect;
- Result:=TCP.Connected;
- except
- Result:=false;
- end;
- finally
- FreeAndNil(TCP);
- end;
- end;
- procedure Tmain.test1Click(Sender: TObject);
- begin
- if CheckURLConnection('google.ru') then
- ShowMessage('Доступен')
- else
- ShowMessage('Недоступен');
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement