Link to home
Start Free TrialLog in
Avatar of irvann
irvann

asked on

Get ping IP result with Delphi

If I pinging an IP Address, what should I do to get pinging result and status  with delphi?
Avatar of Motaz
Motaz

use Indy idicmpClient from Indy Clients page to ping an IP address or computer name:

  idICMPClient1.Host:= 'YourComputerName';
  idICMPClient1.Ping();
  // Then read ReplyStatus:
  Memo1.Lines.Add('Bytes received: ' + IntToStr(idPing.ReplyStatus.BytesReceived));

Motaz
 
Avatar of irvann

ASKER

thank for you fast responses, I'll try it.
Avatar of irvann

ASKER

what 'YourComputerName' as IP? because my computer connected in LAN and when I check in "obtain a IP address automatically", what I fill in 'YourComputerName'?
if you want to pint yourself just use loopback ip 127.0.0.1

but what is the sense of pinging yourself?


BTW is there a fast way to display the delay time of the reply?
Avatar of irvann

ASKER

How to convert this command to Delphi
ping 204.159.0.20 -t
Avatar of irvann

ASKER

How to convert each status from ping to String like command ping?
ASKER CERTIFIED SOLUTION
Avatar of Motaz
Motaz

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of irvann

ASKER

How to get status from ping result(e.g Request time out, etc)?
Avatar of Lukasz Zielinski
go to www.torry.net and look for TICMP component, its great "Ping" useing just core icmp protocol, with sample and source code.
ziolko.
Avatar of irvann

ASKER

Basically i accepted answer from motaz. bUT, Thanks for all comments for my question.
For get status from ping result i find in :
http://www.tutorials.delphi-source.de/indy/file013.shtml
this error  undeclared identifier idping  was occurred  when I used this code:

  idICMPClient1.Host:= 'YourComputerName';
  idICMPClient1.Ping();
  // Then read ReplyStatus:
  Memo1.Lines.Add('Bytes received: ' +  IntToStr(idPing.ReplyStatus.BytesReceived));
So, could anybody help me to know in which type I can declare it?
Regards

Change this line:

Memo1.Lines.Add('Bytes received: ' +   IntToStr(idICMPClient1.ReplyStatus.BytesReceived));