?
Solved

Get ping IP result with Delphi

Posted on 2003-02-18
12
Medium Priority
?
16,074 Views
Last Modified: 2013-11-06
If I pinging an IP Address, what should I do to get pinging result and status  with delphi?
0
Comment
Question by:irvann
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
12 Comments
 
LVL 7

Expert Comment

by:Motaz
ID: 7980153
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
 
0
 

Author Comment

by:irvann
ID: 7980236
thank for you fast responses, I'll try it.
0
 

Author Comment

by:irvann
ID: 7980493
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'?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Expert Comment

by:MethinX
ID: 7980525
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?
0
 

Author Comment

by:irvann
ID: 7980763
How to convert this command to Delphi
ping 204.159.0.20 -t
0
 

Author Comment

by:irvann
ID: 7980812
How to convert each status from ping to String like command ping?
0
 
LVL 7

Accepted Solution

by:
Motaz earned 225 total points
ID: 7992160
I mean by YourComputer is the computer you want to ping, or an IP address

you can put it in loop to simulate ping -t:

Put this in Ping button OnClick:

Finish:= False;
dICMPClient1.Host:= 'YourComputerName';
repeat
  Application.ProcessMessages;
 idICMPClient1.Ping();
 // Then read ReplyStatus:
   Memo1.Lines.Add('Bytes received: ' +   IntToStr(idPing.ReplyStatus.BytesReceived));
until Finish;


and put this code in a button called (Stop):

Finish:= True;

Motaz
0
 

Author Comment

by:irvann
ID: 7992638
How to get status from ping result(e.g Request time out, etc)?
0
 
LVL 21

Expert Comment

by:ziolko
ID: 8014461
go to www.torry.net and look for TICMP component, its great "Ping" useing just core icmp protocol, with sample and source code.
ziolko.
0
 

Author Comment

by:irvann
ID: 8024499
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
0
 

Expert Comment

by:aldahan
ID: 24525430
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

0
 

Expert Comment

by:Júlio
ID: 39629032
Change this line:

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

Featured Post

Introducing Priority Question

Increase expert visibility of your issues by participating in Priority Question, our latest feature for Premium and Team Account holders. Adjust the priority of your question to get emergent issues in front of subject-matter experts for help when you need it most.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses
Course of the Month15 days, 4 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question