Autor Beitrag
Dandrolvorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 21



BeitragVerfasst: Mo 25.04.05 22:49 
Ich pinge verschiedene Hosts OnTimer an.
Doch leider lässt sich währenddessen mein Programm nich mehr ansprechen.
Was lässt sich tun?
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Mo 25.04.05 22:55 
ausblenden Delphi-Quelltext
1:
application.processmessages;					

oder erstellung eines threads mit der ping-prozedur

_________________
es gibt leute, die sind genetisch nicht zum programmieren geschaffen.
in der regel haben diese leute die regel...
Dandrolvorn Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 21



BeitragVerfasst: Di 26.04.05 06:25 
Also, mit Application.ProcessMessages hab ich es schon ausprobiert, ich habe aber keine
Ahnung, wo das in diesen Codes hingehört

Der Timer:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure TMainForm.pingTimer(Sender: TObject);
var
 i: Integer;
begin
 For i := 0 to ((serverlines div 7) - 1) do
  begin
   server[i].online :=  anping(server[i].url);
  end;
end;


Die Ping Funktion:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
function anping(host: String):boolean;
var
 MS: Integer;
 ICMP: TidIcmpClient;
begin
    ICMP:= TidICMPClient.Create(nil);
    result:= False;
    ICMP.Host:= host;
    ICMP.Ping;
    MS:=ICMP.ReplyStatus.MsRoundTripTime;
    result:= ICMP.ReplyStatus.ReplyStatusType <> rsTimeOut;
    ICMP.Free;
end;


Ich hoffe ihr könnt damit was anfangen ... ^^

Moderiert von user profile iconraziel: Code- durch Delphi-Tags ersetzt.
Harry M.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 754

Win 2000, XP
D2005
BeitragVerfasst: Di 26.04.05 07:52 
ich nehme mal an das liegt an der schfleife in der du pingst. und du darst auch nicht vergessen, das dein ICMP einen stardart timeout von 5000 hat.

_________________
Gruß Harry
Et spes me per dies sine te ducat et amor me ferat, si dolor spem tollit.
Dandrolvorn Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 21



BeitragVerfasst: Di 26.04.05 12:09 
Sry Harry, aber ich wüsste an Hand deiner "Lösung" nich was ich umstellen sollte, könntest du etwas konkreter werden?

bzw. mir vllt. auch einen Vorschlag machen, wie es besser geht?
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Di 26.04.05 12:28 
guck dir mal den link bei meinem oberen beitrag an. im sourcecode des programmes findest du die funktion createthread, die die ping-prozedur in einem eigenen thread startet. dadurch hat dein hauptprogramm immer "die hände frei"

_________________
es gibt leute, die sind genetisch nicht zum programmieren geschaffen.
in der regel haben diese leute die regel...
Dandrolvorn Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 21



BeitragVerfasst: Di 26.04.05 20:49 
Das ganze läuft nu ohne Probleme in einem Thread, danke nochmal ;)

Allerdings tut sich jetzt ein neues Problem auf.
das Ping signal wird von Firewalls verschluckt, obwohl ich auf einen Port pinge der nachweislich offen is, und der Server is auch On.
Hier nochmal mein Ping code:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
function anping(host, port: String):boolean;
var
 //MS: Integer;
 ICMP: TidIcmpClient;
begin
    ICMP:= TidICMPClient.Create(nil);
    result:= False;
    ICMP.Host:= host;
    ICMP.Port := strtoint(port);
    ICMP.Ping;
    //MS:=ICMP.ReplyStatus.MsRoundTripTime;
    result:= ICMP.ReplyStatus.ReplyStatusType <> rsTimeOut;
    ICMP.Free;
end;


Moderiert von user profile iconraziel: Code- durch Delphi-Tags ersetzt.
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Di 26.04.05 21:31 
ich wusste gar nicht dass man für pings einen port benötigt :gruebel:
checke mal ob deine firewall icmp erlaubt

_________________
es gibt leute, die sind genetisch nicht zum programmieren geschaffen.
in der regel haben diese leute die regel...
Harry M.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 754

Win 2000, XP
D2005
BeitragVerfasst: Di 26.04.05 21:44 
das mit dem thread ist ne feine sache. hat mir auch weitergeholfen :lol: warum das singnal von der firewall geschluckt wird weiß ich nicht. ist wahrscheinlich ihre aufgabe... (liegt immer an der einstellungen der firewall)

die hilfe verrät folgendes: Port is an Integer property that identifies the port number on the local system where data is sent and received.

_________________
Gruß Harry
Et spes me per dies sine te ducat et amor me ferat, si dolor spem tollit.
Dandrolvorn Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 21



BeitragVerfasst: Mi 27.04.05 10:34 
Ich habe nachgefragt, ich muss den Ping an Port 10300 senden. Wie kann ich das realisieren?
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Mi 27.04.05 10:38 
das ist blödsinn, für ICMP werden keine ports benötigt.

_________________
es gibt leute, die sind genetisch nicht zum programmieren geschaffen.
in der regel haben diese leute die regel...
Dandrolvorn Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 21



BeitragVerfasst: Mi 27.04.05 10:48 
Dann muss ich das ping-Signal irgendwie anders absetzen. Ich _muss_ (so wurde es mir erzählt) das ping Signal an Port 10300 setzen. Meine Frage war, wie?
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Mi 27.04.05 10:55 
es geht nicht, da ICMP ein connection-less-protocol ist

_________________
es gibt leute, die sind genetisch nicht zum programmieren geschaffen.
in der regel haben diese leute die regel...
Harry M.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 754

Win 2000, XP
D2005
BeitragVerfasst: Mi 27.04.05 11:04 
Wenn Du sicher bist, den Host, den Du anpingen willst auch zuerreichen, dann frage lieber den Port ob, ob er offen bzw. geschlossen ist.

_________________
Gruß Harry
Et spes me per dies sine te ducat et amor me ferat, si dolor spem tollit.
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Mi 27.04.05 11:09 
ich hab hier was für euch schlaumeier: www.computerbetrug.de/netzwerk-icmp.php

_________________
es gibt leute, die sind genetisch nicht zum programmieren geschaffen.
in der regel haben diese leute die regel...
Dandrolvorn Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 21



BeitragVerfasst: Mi 27.04.05 22:39 
Dann muss ich irgendwie anders pingen ... gibt es da nich eine Routine?
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Do 28.04.05 00:26 
ich hab dir eine geschrieben: www.delphi-forum.de/....php?p=246460#246460

_________________
es gibt leute, die sind genetisch nicht zum programmieren geschaffen.
in der regel haben diese leute die regel...
Dandrolvorn Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 21



BeitragVerfasst: Do 28.04.05 13:57 
Danke dafür, aber ich muss ehrlich sagen, dass ich nich weiß, wie ich das in mein Programm einbauen kann.
Und ich habe da nichts mit Port entdeckt ...
Harry M.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 754

Win 2000, XP
D2005
BeitragVerfasst: Do 28.04.05 14:05 
user profile iconDandrolvorn hat folgendes geschrieben:
Ich _muss_ (so wurde es mir erzählt) das ping Signal an Port 10300 setzen.

Verstehst Du es nicht oder willst Du es nicht verstehen?? Es gibt keinen Port auf den man pingen kann! Obige Link fürht zu einem API Beispiel-Code und wenn man keinen Port braucht, wirst Du auch dort keinen finden. Und wenn Du Leuten glaubt die Dir das erzählen dann tu das...

_________________
Gruß Harry
Et spes me per dies sine te ducat et amor me ferat, si dolor spem tollit.
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Do 28.04.05 19:54 
user profile iconDandrolvorn hat folgendes geschrieben:
Danke dafür, aber ich muss ehrlich sagen, dass ich nich weiß, wie ich das in mein Programm einbauen kann.
Und ich habe da nichts mit Port entdeckt ...


ganz einfach: kopier dir die 3 functions aus dem quelltext, und füge sie in deinem quelltext ein. dann brauchst du nur noch einen aufruf für die ping-funktion:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
var
  host:string;
  code: dword;
  hopCount:dword;
  RTT:dword;
  count:integer;

....

      code := ping(host,hopcount,rtt);
      if code = 0 then
        writeln('hops: ', hopCount,'  roundtrip time : ', RTT, ' ms.') // hier der code, falls eine antwort kommt
      else
        writeln('Error: ', code); // hier der code, wenn ein fehler auftritt

falls dann noch eine fehlermeldung kommt, musst du noch WINSOCK bei uses hinzufügen.

_________________
es gibt leute, die sind genetisch nicht zum programmieren geschaffen.
in der regel haben diese leute die regel...