Jump to content
  • Advertisement
Sign in to follow this  
the_moo

Is this how I would ping?

This topic is 4813 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hey all, I've just been reading up on what you do to ping but i'm not sure if i have the right idea about going about finding other computers on a network and getting their addresses by ping-ing. my thought: send a small message (say "PING") out to every address on the network (so like "192.056.0.xxx" and go through all 1000 numbers for "xxx"). now this is how i understand ping-ing but wouldnt this take a while to complete? i haven't implemented it yet (since that won't be too hard now that i have my send/receive setup) so i just wanted to see if this is a correct way of ping-ing so i dont freeze my computers or something while trying to do it if it is wrong. also, if it is wrong, please explain how i should go about finding computers to connect to on a network for me. thanks for any info. ps. sorry if this is kinda noob. im new to the whole network programming scene [wink]

Share this post


Link to post
Share on other sites
Advertisement
Don't worry, there's a much easier way. :-)

Instead of sending a ping to all 255 (not 1000) addresses on your local network, simply send ping to 255.255.255.255. This is a special "broadcast" address you can use to send messages to ALL computers on a local network. Any computer on your LAN listening for such a ping will recieve it.

Share this post


Link to post
Share on other sites
What you probably really want to do is find out the broadcast address for the network you're on, set the socket so that it will send on the broadcast address (using setsockopt() and SO_BROADCAST), and send your message out on the broadcast address that way you only have to send out one message... all of the computers should reply to that one message.

Also the max value for any part of an IP address is 255, not 999.

Share this post


Link to post
Share on other sites
awesome!
thanks for that you two.
and thanks for the very quick replies too.

also, i did know the max was 255... had a mental blank [wink].
thanks again,

Share this post


Link to post
Share on other sites
hi could i use this to send privite messages to each other on a network if i know the other person's ip and what will i need to do for it to work?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!