Can someone point me to some tutorial on how to set up a ping method using C sockets? Using beej’s guide, I’ve been able to set up a connection between two devices, but now I want to setup a method that pings for all available devices before starting an actual connection. I’ve never done this before, so would you do something like set up a multicast socket to broadcast an empty data packet and then have the receiver of that empty packet fill it with their IP address and return that now full data packet so that you have the address to start the connection? Any guide’s/ help would be appreciated!
Share
Most current IP stacks will not respond to a ping request to a broadcast address. The feature was abused for denial of service attacks.
Implementing a real ping implementation won’t be easy, I’d suggest you use an existing lib:
http://www.kernelthread.com/projects/hanoi/html/icmp.html
But you will have to manually iterate through all of the IP addrs on your subnet to get them to respond.