Sign in to follow this  
BANE000

Server broadcasting to find clients

Recommended Posts

In the FAQ it says that finding your own IP is A Bad Thing(tm), so what would be the best manner to send a broadcast message to announce that there is a server available for clients to join? Obviously, if finding the local IP is a valid design concept, then it would be simple to determine the class of the address and replace the appropriate number of fields with 255. This is simple but not very elegant. Is there a better way? Thanks!

Share this post


Link to post
Share on other sites
Most routers will filter UDP broadcasts. Thus, if you broadcast on the "Mars" address (255.255.255.255) and on your specific port, then the local machines that see your server will know where to reply back to, because the return address will be in their call to recvfrom(). Note that you need to do a special socket ioctl() before you're allowed to broadcast.

If you want to announce availability of the server wider than your local subnet, you have to use some sort of separate look-up, such as a known server/roster/introducer, or just plain DNS. Multicast is not really an alternative, because it's not well supported on the Internet in general (probably because it's a pretty poor match to today's Internet).

Share this post


Link to post
Share on other sites
Well, if what you want to do is have a server with a non static ip then yes some kind of dns service with something like no-ip.org is appropriate.

But it sounds as if you're thinking of being able to see servers as in say Quake, Half-Life, Starcraft, Diablo etc. These games just use a known central server where all the player servers report their status and availability.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this