2 Replies Latest reply: Aug 20, 2013 6:48 PM by morgalr RSS

    Find Address of Server


      I would like to be able to find the address of a server on my local network.

      I've been doinking around (specific local technical therm there) with a game idea, and in my thought process of designing the game I'd like to make the following happen in the implementation:

      I or anyone present can get online to play the game (not a problem I can program sockets).

      When a potential player comes on line, they would choose if they want to host the game or just participate, and if there are hosts already present, give them a list that are available to join.  Herein is my problem.  The server IP address would not be known at the time anyone comes online, and it could be any address covered in my local block 10.0.0.XXX or 192.168.0.XXX, well, except the router address.

      In all the work I've done in the past, the server IP address has always been known.  Also in the examples I have from the net and from my books everything assumes you know the IP address of the server, that approach is not a problem and I've done it many times, but now I am looking for the basic idea of how do "discover a server on the network".

      What I've thought so far is: use a bruit force type of algo where the client literally just checks everything in the local block using the protocol for the game.  Is that the way to do it using simple TCP/IP and Java or is there a more elegant way that I'm missing?

      I am not looking for coding examples, but just the basic idea verification or approach... even a suggested google search would be appreciated.

        • 1. Re: Find Address of Server

          As long as it is the local network and as long as the router (or other network infrastructure) does not disallow it you can use a UDP.  When a server comes on line and perhaps and timed intervals after that it broadcasts a "Server here" message on a UDP port.


          Clients listen on the UDP port and collect addresses.


          The alternative to that, when UDP is not possible (internet) is to have a dedicated communications server that is accessible to everyone.  It does nothing but indicate what servers are up.  Servers post availability and clients request server lists.

          • 2. Re: Find Address of Server

            Thank you for the response.  After checking my router and looking around a bit, I see the UDP block operations are disabled on my router, so I do not think I will be persuing that avenue, and realistically this is going to be me and my family and maybe a few friends sitting around the house with our laptops and somebody says: Hey, let's play XYZ game so the lookup server options is not a good scenario either.


            It did give me a reality check though -- I realistically can expect to only have to check the first few local IP addresses for this type of implementation, so the bruit force approach will work ok on the scale I'm implementing.


            Thank you for your input!