![]() |
ping host + socketfehler
Hi, ich kriege immer einen Scketfehler, liegt bestimmt an try expect?!
Delphi-Quellcode:
function Ping(Host: String):string;
var res: TReplyStatus; ICMP: TidIcmpClient; // indy-Clients begin ICMP:= TidICMPClient.Create(nil); result:= 'offline'; ICMP.Host:= Host; try ICMP.Ping; except result:= 'connected?'; End; if ICMP.ReplyStatus.ReplyStatusType <> rsTimeOut= true then result:='online' else result:='offline' ICMP.Free; end; |
Re: ping host + socketfehler
Hallo,
ich würde das eher so machen:
Delphi-Quellcode:
In dem except Block könntest du noch die exception Abfangen und den Fehlertext ermitteln, damit man sieht woran es liegt.
function Ping(Host: String):string;
var res: TReplyStatus; ICMP: TidIcmpClient; // indy-Clients begin ICMP:= TidICMPClient.Create(nil); try result:= 'offline'; ICMP.Host:= Host; try ICMP.Ping; if ICMP.ReplyStatus.ReplyStatusType <> rsTimeOut then result:='online' else result:='offline'; except result:= 'connected?'; end; finally ICMP.Free; end; end; |
Re: ping host + socketfehler
Hi, ich habe das jetzt aus probiert und erscheint mir alles schlüssig, aber obwohl ich mit dem Internet verbunden bin kriege ich immmer not connected raus.
Hier nochmal der ganze Quelltext (Die Seiten sind alle online)
Delphi-Quellcode:
procedure TShedlstat.FormCreate(Sender: TObject);
function Ping(Host: String):string; var res: TReplyStatus; ICMP: TidIcmpClient; // indy-Clients begin ICMP:= TidICMPClient.Create(nil); try result:= 'offline'; ICMP.Host:= Host; try ICMP.Ping; if ICMP.ReplyStatus.ReplyStatusType <> rsTimeOut then result:='online' else result:='offline'; except result:= 'not connected'; end; finally ICMP.Free; end; end; Var i:integer;Var pref,actual_pref:IXMLDOMnode; server,status:string; xmlDoc: IXMLDOMDocument2; Begin for i:=1 to 5 do Case i of 1:Label9.Caption:=ping('http://setiboinc.ssl.berkeley.edu/sah_cgi/cgi'); 2:Label10.Caption:=ping('http://predictor.scripps.edu/predictor_cgi/cgi'); 3:Label11.Caption:=ping('http://climateapps2.oucs.ox.ac.uk/cpdnboinc_cgi/cgi'); 4:Label12.Caption:=ping('http://lhcathome.cern.ch/lhc_cgi/cgi'); 5:Label13.Caption:=ping('http://einstein.phys.uwm.edu/EinsteinAtHome_cgi/cgi'); End; //case end; |
Re: ping host + socketfehler
ähm du kannst doch keine urls pingen o_O
du musst schon den server nehmen und ausserdem könnten die auch ne ICMP verwerfende firewall aktiv haben |
Re: ping host + socketfehler
Dann könnte ich doch theoretisch nur rausfinden, ob eine Iaddi onlie ist, wenn Daten gesendet werden?
|
Re: ping host + socketfehler
Zitat:
Delphi-Quellcode:
Begin
for i:=1 to 5 do Case i of 1:Label9.Caption:=ping('setiboinc.ssl.berkeley.edu'); 2:Label10.Caption:=ping('predictor.scripps.edu'); 3:Label11.Caption:=ping('climateapps2.oucs.ox.ac.uk'); 4:Label12.Caption:=ping('lhcathome.cern.ch'); 5:Label13.Caption:=ping('einstein.phys.uwm.edu'); End; //case end; |
Re: ping host + socketfehler
Zitat:
Dann wird <scheduler_reply> <message priority="low">Incomplete request received.</message> </scheduler_reply> zurückgegeben, also Daten gesendet. Habe das jetzt so gelöst, was denkt ihr:
Delphi-Quellcode:
Iadd:= 'http://setiboinc.ssl.berkeley.edu/sah_cgi/cgi';
if not FileExists(Iadd) then label9.Caption:='offline' ; xmlDoc:=CoDomDocument40.Create; xmlDoc.setProperty('NewParser',true); xmlDoc.load(Iadd) ; if xmlDoc.parseError.errorCode = 0 then Begin label9.Caption:='online' End; |
Re: ping host + socketfehler
Zitat:
Alleine das "http://" gehört ja schon nicht mehr zur Adresse sondern definiert für den Browser nur das Protokoll das er verwenden soll. |
Re: ping host + socketfehler
Na egal, trotzdem danke, werde das jetzt Mal über XML versuchen, ob die Seite geladen werden kann.
(Vielleicht bekomme ich auch irgendwie die IP raus ;-)) |
Re: ping host + socketfehler
P.S.
Habe das hier gefunden: (mit Indy IdHttp)
Delphi-Quellcode:
function Ping(Host: String):string;
Begin try idhttp.Get(host); result:='online'; except on EIdFileNotFound do result:='offline'; end; end; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 01:56 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz