title: Java network game: How to list available servers?
body: <p>I'm working on a game that uses local area network. Like most of multiplayer games, there is a server-client system. Computer A runs an instance of program, creates a server and wait; Computer B do the same thing. Now Computer C runs the program, what I want is that he can see computer A and B listed there as game servers. How can I do this?<br/>
  In order to list all of the servers available, a simple solution might be this: I need to check all of the IP addresses in a particular range and see if they respond via my specific port or not. If yes, therefor an instance of game is running on it and should be listed in the servers list.<br/>
  Is the solution described above a good one?
  I've searched and get this piece of code:</p>
  
  <pre><code>public void checkHosts(String subnet){
      int timeout=1000;
      for (int i=1;i&lt;254;i++){
          String host=subnet + "." + i;
              if (InetAddress.getByName(host).isReachable(timeout)){
                  System.out.println(host + " is reachable");
              }
      }
  }
  </code></pre>
  
  <p>but is takes so much time and is useless.
  If it's not the right solution, what are some other ways?</p>