Autor Beitrag
Gesus
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 43



BeitragVerfasst: Di 06.07.04 16:54 
Hallo Leute!

Ich habe jetzt in dem Forum bestimmt 10 Thread durchgelesen, welche sich mit dem Thema Pingen beschäftigen, aber ich raff es echt nicht.. bin halt viiiel zu neu in dem Gebiet Delphi!

Meine Frage: Ich habe jetzt bsp. ein Edit-Feld. Nun möchte ich erkennen ob bei einem Buttenklick der Nutzer (bsp. "Gesus") in dem Netzwerk online ist.
Ich habe viel gelesen aber nicht verstanden! Könnte ein netter Programmierer (oder Nachhilfe Lehrer) mir das mal bitte erklären?

Danke!
MSCH
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1448
Erhaltene Danke: 3

W7 64
XE2, SQL, DevExpress, DevArt, Oracle, SQLServer
BeitragVerfasst: Di 06.07.04 19:38 
na aber klar doch
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
function Ping(Host: String; // wohin IP oder Name des Rechners
  var MS: integer  // Rückgabe anzahl ms
  ): Boolean;  // host übrhaupt erreichbar ja=true else false
var res: TReplyStatus;
    ICMP: TidIcmpClient;  // indy-Clients
begin
  ICMP:= TidICMPClient.Create(nil); 
  result:= False;
  ICMP.Host:= Host;
  ICMP.Ping;
  MS:=ICMP.ReplyStatus.MsRoundTripTime;
  result:= ICMP.ReplyStatus.ReplyStatusType <> rsTimeOut;
  ICMP.Free;
end;

grez
msch

_________________
ist das politisch, wenn ich linksdrehenden Joghurt haben möchte?
Softchaos67
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 103

XP Prof
Delphi 7
BeitragVerfasst: Do 14.10.04 11:55 
Hallo,
ich hab das so nachgebaut,
aber wenn ein Host nicht erreichbar ist bekomme ich ne Fehlermeldung.
Wie kann ich diese unterdrücken?
Bei mir sieht das so aus:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
procedure TfrmLogVerw.CheckConnect;
var
   i ,
   ms :integer;
begin
   With ColorStrGrd1 do
     for i := 1 to ColorStrGrd1.RowCount -1 do begin
        IdIcmpClient1.Host:=Cells[8,i];  //Eine IP-Adresse
        IdIcmpClient1.Ping;              // Will sehen ob sie erreichbar ist  
        MS:=IdIcmpClient1.ReplyStatus.MsRoundTripTime;        // hab ich so übernommen
        if IdIcmpClient1.ReplyStatus.ReplyStatusType<>rsTimeOut  then ColorStrGrd1.Objects[9,i] := Pointer(1) 
                                                                 else ColorStrGrd1.Objects[9,i] := Pointer(2);
       //hir merk ich mir obs geklappt hat
   end;
end;

Wenn der Host nicht existiert bekomme ich ne exeption. Es soll aber gar nichts weiter passieren.
Irgendwelche ideen?
Gruss
Matthias
GSE
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 740

Win 2k, Win XP Pro
D5 Prof, D6 Ent, D2k5 PE
BeitragVerfasst: Do 14.10.04 12:30 
try
except
?
Fehlerhandling?

mfg
GSE

_________________
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs
and the universe trying to produce bigger and better idiots. So far, the universe is winning. (Richard Cook)
Softchaos67
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 103

XP Prof
Delphi 7
BeitragVerfasst: Do 14.10.04 12:48 
Danke,
hat sich erledigt.
Der Fehler kommt nur bei ner ungültigen IP, nicht wenn der Host nicht verfügbar ist.
Dafür dass die IP gültig ist bin ich schon selber zuständig.
Trotzdem Danke
Gruss
Matthias
Hackbert
Hält's aus hier
Beiträge: 7



BeitragVerfasst: Di 26.04.05 21:12 
Raff ich nun gartnicht mehr...

habe beide quellcodes probiert.. aber zeigt nur fehler an...


kann mir einer ein kompletten Source senden ?

Brauch ich dlls oder irgendwas???


Habe DELPHI 7
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:23 
für diese version brauchst du die indy-komponenten, geht aber auch ohne.

_________________
es gibt leute, die sind genetisch nicht zum programmieren geschaffen.
in der regel haben diese leute die regel...
Hackbert
Hält's aus hier
Beiträge: 7



BeitragVerfasst: Di 26.04.05 22:37 
so ich habe des indy 10 installiert...
nun weiss ich net weiter.. hmm..

hat nicht jemand ein project?


uch will jmd pingen und des denn angezeigt bekommen... wieivel ms...

ausblenden Delphi-Quelltext
1:
2:
3:
IdIcmpClient1.host('192.168.1.1');
IdIcmpClient1.ping;
IdIcmpClient1.ReplyStatus.MsRoundTripTime


jo wie jetzt String to CADINAL ???

Moderiert von user profile iconraziel: Delphi-Tags hinzugefügt.
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 23:13 
klick mal unter indy clients TIDIcmpClient an und zieh es auf dein formular.
dann werden der USES-klausel die nötigen units hinzugefügt. danach kannst du das symbol wieder von deiner form entfernen und einen der codes hier verwenden, Suche in: Delphi-Forum, Delphi-Library TIDICMPCLIENT

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

Windows Vista Ultimate
D7 Enterprise
BeitragVerfasst: Mi 27.04.05 00:05 
Mit cardinal kannst du im endeffekt genauso umgehen wie mit integer. StrToInt und IntToStr sollten es tun.

_________________
>+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.
Hackbert
Hält's aus hier
Beiträge: 7



BeitragVerfasst: Do 28.04.05 21:50 
THX hat geklappt.. so jetzt neues problem...

ich wollte machen das er jede sekunde neu anpingt und des mir ausgibt...

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
IdIcmpClient1.Host := Edit1.Text;
IdIcmpClient1.ping;
Label1.Caption:=inttostr(IdIcmpClient1.ReplyStatus.MsRoundTripTime);
sleep(1000);
IdIcmpClient1.ping;
label1.Caption:=inttostr(IdIcmpClient1.ReplyStatus.MsRoundTripTime);


geht aber leider nicht...

wie mach ich des
JayEff
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2971

Windows Vista Ultimate
D7 Enterprise
BeitragVerfasst: Do 28.04.05 21:56 
sleep ist auch recht unsauber, es friert dein gesammtes programm ein. versuche lieber das ganze in nen timer zu packen. initialisiere den Client Host ausserhalb des Timers und aktiviere diesen danach. dann klappt das auch ;)

_________________
>+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.
Hackbert
Hält's aus hier
Beiträge: 7



BeitragVerfasst: Do 28.04.05 22:29 
habe davon keien ahnung....
JayEff
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2971

Windows Vista Ultimate
D7 Enterprise
BeitragVerfasst: Do 28.04.05 22:35 
Schau einfach mal unter "System" nach der Komponente TTimer. Zieh einen auf die Form und doppelklicke drauf. nun kannst du den code einfügen, der einmal pro sekunde ausgeführt werden soll. im objektinspektor kannst du das interval in milisekunden einstellen.

_________________
>+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.
Hackbert
Hält's aus hier
Beiträge: 7



BeitragVerfasst: Sa 30.04.05 09:41 
thx.. die uhr hatte schonmal benutzt aber dachte mit macht kein sin nwenn doppelklick dadruff...
naja THX es funzt....

so jetzt arbeite ich am TIMEOUT mit INDY aber hmm will net so...


ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
procedure TForm1.Timer1Timer(Sender: TObject);
begin

try
 IdICMPClient1.ReceiveTimeout:=5000;
 IdIcmpClient1.Host := Edit1.Text;
 IdIcmpClient1.ping;
 Label1.Caption:=inttostr(IdIcmpClient1.ReplyStatus.MsRoundTripTime);
except
 Label1.Caption:='Timeout';
end;

end;
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: Sa 30.04.05 11:09 
probier mal den code aus: www.delphi-forum.de/....php?p=247236#247236
das ganze ohne die indy-komponenten realisiert.

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