Einzelnen Beitrag anzeigen

Benutzerbild von Sherlock
Sherlock

Registriert seit: 10. Jan 2006
Ort: Offenbach
3.764 Beiträge
 
Delphi 11 Alexandria
 
#5

AW: Fehlerbehandlung SOAP Webservice THTTPRio

  Alt 26. Okt 2018, 10:38
Grundsätzlich kann man mit einem TIdTCPClient testweise eine Verbindung zum Serverport herstellen. Sowas in der Art:
Delphi-Quellcode:
function IsServerAvailable(const aHostName:string; const aPort:Cardinal):Boolean;
const
  Timeout_ms = 1000;
var
  tcp: TIdTCPClient;
begin
  Result := False;
  tcp := TIdTCPClient.Create(nil);
  try
    tcp.Host := AHostName;
    tcp.Port := APort;
    tcp.ReadTimeout := Timeout_ms;
    tcp.ConnectTimeout := Timeout_ms;
    try
      tcp.Connect;
      tcp.Disconnect;
      Result := True; // Success
    except
      on E: Exception do
      begin
        Result := False; // Not reachable
      end;
    end;
  finally
    tcp.Free;
  end;
Sherlock
Oliver
Geändert von Sherlock (Morgen um 16:78 Uhr) Grund: Weil ich es kann
  Mit Zitat antworten Zitat