well if i need to ping a range of ips I can use a small script like this#!/bin/bash
for i in { 1…50}
do ping -c2 192.168.0.$i &> /dev/null
if $?=0 ]; then
echo “UP”
else
echo “DOWN”
fi
done
But I need to do this via a C program . How can I achieve the same ?
You can do this with Socket programming in C.
Are you familiar with C programming?
If you are not familiar with Socket programming, you may execute the “ping command” from within your C program and use the result in your program.
The equivalent for my network scanned my entire class C in three seconds
(three hosts up, 251 down).
Good luck.
ken yap wrote:
> You might want to look at the fping utility, which can do multiple pings
> in parallel and also allows you to specify the range on the command
> line.
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org