Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

C Programming Language

ping


how to ping ip address from c language ?

Sonda <wfialkiew@hotmail.com> writes:
> 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/programming/iphlpapi/send-icmp.php

Regards
Friedrich

--
Please remove just-for-news- to reply via e-mail.

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>

Tor Rustad <tor@online.no> writes:
> 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 <pre> directive 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) k@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"

Keith Thompson wrote:
> Tor Rustad <tor@online.no> writes:
>> 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>

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.          ------

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc