473,378 Members | 1,309 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

ping

how to ping ip address from c language ?

May 25 '07 #1
5 7387
Sonda <wf**********@hotmail.comwrites:
how to ping ip address from c language ?
I guess you do not like the idea of using system?
However that's the only way for doing that "portable".
However if you leave Ansi-C grounds you surely will find a acceptable
solution. See e.g
http://english.geekpage.jp/programmi.../send-icmp.php

Regards
Friedrich

--
Please remove just-for-news- to reply via e-mail.
May 25 '07 #2
Sonda wrote:
how to ping ip address from c language ?
http://www.faqs.org/rfcs/rfc792.html

The inventor of ping, Mike Muuss, wrote the first ping program in day.. and
put it into public domain:

http://www.ping127001.com/pingpage/ping.html

--
Tor <torust [at] online [dot] no>

May 25 '07 #3
Tor Rustad <to****@online.nowrites:
Sonda wrote:
>how to ping ip address from c language ?

http://www.faqs.org/rfcs/rfc792.html

The inventor of ping, Mike Muuss, wrote the first ping program in day.. and
put it into public domain:

http://www.ping127001.com/pingpage/ping.html
It's a pity that it's provided with a ".html" suffix. When I view the
page in my browser, the #include directives are messed up, and
probably other things as well.

The problem is that the <predirective doesn't actually say to
display plain text without interpreting it; things that look like HTML
directives are still processed.

You can download the raw file, remove everything up to and including
the "<pre>" directive, and try to compile it.

But note that the code is inherently non-portable (as it must be,
since standard C doesn't have the required facilities). Of the
headers it includes, only two are standard:

#include <stdio.h>
#include <errno.h>
#include <sys/time.h>

#include <sys/param.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/file.h>

#include <netinet/in_systm.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <netinet/ip_icmp.h>
#include <netdb.h>

And it failed to compile on four different systems I just tried
(Cygwin, Solaris, Red Hat, AIX) -- all of which already have their own
"ping" programs, of course.

A solution to the original problem that's fairly likely to work on any
system where this is even possible is

system("ping ...");

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
May 25 '07 #4
Keith Thompson wrote:
Tor Rustad <to****@online.nowrites:
>The inventor of ping, Mike Muuss, wrote the first ping program in day..
and put it into public domain:

http://www.ping127001.com/pingpage/ping.html

It's a pity that it's provided with a ".html" suffix. When I view the
page in my browser, the #include directives are messed up, and
probably other things as well.
Yeah, I used "View Source" function in the browser, or you could get the raw
page via wget... or telnet.

And it failed to compile on four different systems I just tried
(Cygwin, Solaris, Red Hat, AIX) -- all of which already have their own
"ping" programs, of course.
Hehe.. you might have better luck with BSD installation from 1983! Still
it's an interesting read of a historical hack:

http://ftp.arl.mil:80/~mike/ping.html
--
Tor <torust [at] online [dot] no>

May 26 '07 #5
Tor Rustad wrote:
Sonda wrote:
>how to ping ip address from c language ?

http://www.faqs.org/rfcs/rfc792.html

The inventor of ping, Mike Muuss, wrote the first ping program in day.. and
put it into public domain:

http://www.ping127001.com/pingpage/ping.html
As an alternative, here's the source code link from Mike's webpage
http://ftp.arl.army.mil/pub/ping.shar

If you want the whole story about ping, Mike's page gives the scoop:
http://ftp.arl.mil/~mike/ping.html

--
Lew Pitcher

Master Codewright & JOAT-in-training | Registered Linux User #112576
http://pitcher.digitalfreehold.ca/ | GPG public key available by request
---------- Slackware - Because I know what I'm doing. ------

May 28 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Jason Rodman | last post by:
I have downloaded every example on how to create a ping utility in .Net in both VB and C#, but have been disappointed with the results. I have YET to find an example that returns consistent results...
9
by: Mantorok | last post by:
Hi all I want to ping an ipaddress/host to check for a response. Is there any easy way in C#/.Net to do this? Thanks Kev
2
by: Eric Wenger | last post by:
I'm pretty new to C# and I'm trying to do what I believe should be a simple thing. I want to modify a program that is using the System.Net.NetworkInformation.Ping class to have some custom...
0
by: Ed | last post by:
I've attached some VB.NET code I've hacked together (some taken from MS examples & newsgroup postings) that will perform a ping or IcmpSendEcho using the icmp.dll (see this for more info:...
0
by: scotty | last post by:
I need to do a ping scan of a subnet. I can Enum through the IPs and do this, but it takes over 5 minutes as I can only create 1 process at a time. Does anyone know how I can create multiple Ping...
21
by: Neel | last post by:
I am trying to "ping" a remote host in my C++/Redhat Linux code to check whether that host is connected or not. if (0 == system("ping -w 2 192.168.0.2)) But, in both cases...
5
by: Deepak | last post by:
I am programing a ping application which pings various centers . I used timer loop and it pings one by one. Now when i finish pinging one center it should wait for the ping_completed function to...
1
by: Krish | last post by:
All, I have an offline application that works online for some data syncronization. For data syncronization I access a webservice. I want to show whether my application is online or not by checking...
3
by: imughal | last post by:
I got the perl script which does following task. This solution reads in a line from a text file that is passed in as input parameter 1 to a Perl script. This script will then ping the machine...
6
by: Dave Marden | last post by:
I currently use this routine in vbscript to ping computers and get the status of ping to determine whether to try to backup a machine, I am trying to change it to work with vb2003.net I am...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.