Dear friends,
i want to make a C program which can ping an IP and provide the status whether that device is available or not in the form of some integer value i.e for available give '1' and other for NULL

12-29-2008

Salem

You mean like what the "ping" program does?

12-29-2008

laserlight

Moved to Networking/Device Communication.

12-29-2008

BobS0327

You may want to consider the ICMP API if you're on the Windows platform.

12-29-2008

brewbuck

Quote:

Originally Posted by krishna

Dear friends,
i want to make a C program which can ping an IP and provide the status whether that device is available or not in the form of some integer value i.e for available give '1' and other for NULL

First thing to realize, is that just because a device does not respond to an ICMP "ping", does not mean that device is unavailable. It just might not be responding to ping, for many legitimate reasons.

12-29-2008

matsp

Quote:

Originally Posted by brewbuck

First thing to realize, is that just because a device does not respond to an ICMP "ping", does not mean that device is unavailable. It just might not be responding to ping, for many legitimate reasons.

Not to mention that if the device isn't connected directly to the computer running such a PING operation, it can fail at any level in between, and the device is in itself perfectly operational, just that some segment of network in between failed [or didn't forward the PING or PING-REPLY message] for some reason.

--
Mats

12-29-2008

BobS0327

RFC 792 provides a lot of info on the ICMP messages including a detailed breakdown of destination unreachable codes.

02-14-2009

edomingox

ok. so how do you make a program that will ping an address, regardless if the results are positive or negative?

02-14-2009

Salem

Seriously, what are you trying to do?

You "make" the program by reading the RFC, writing code to send out the right kind of message, then interpreting the responses (or lack of).

If you don't know how to do that, then looking at an existing "ping.c" program might help. But the good ones (with a reasonable level of functionality) are not exactly small.

Or if you just don't want to know about the code, just write a simple wrapper around the "ping" program which comes with your OS.