tags:

views:

290

answers:

3

I want to implement ping request in C language.I am working on Windows platform.Can any one suggest how to implement it or if code is already available then from where i can find it?

A: 

You can use system() to run command line instructions. So something like

system("ping 127.0.0.1")

should work.

m0rb
i think system is command which works in Linux only.
Ashish Bhadiyadra
No, system() works anywhere. And Windows does have a ping executable.
paxdiablo
That i can do but actually i want to store average round trip time, which comes after executing ping request through system(), in database.Invoking system() how can i get that round trip time?
Ashish Bhadiyadra
+1  A: 

Pls check if these links are helpful:

Source for a PING in C

icmpquery.c

aJ
I think these codes are dependent on Linux platform.but i am working on windows.
Ashish Bhadiyadra
+2  A: 

Highly useful and open source - fping.

fping is a ping(1) like program which uses the Internet Control Message Protocol (ICMP) echo request to determine if a host is up. fping is different from ping in that you can specify any number of hosts on the command line, or specify a file containing the lists of hosts to ping. Instead of trying one host until it timeouts or replies, fping will send out a ping packet and move on to the next host in a round-robin fashion. If a host replies, it is noted and removed from the list of hosts to check. If a host does not respond within a certain time limit and/or retry limit it will be considered unreachable.

Unlike ping, fping is meant to be used in scripts and its output is easy to parse.

gimel