public InetAddress discoverHost(int udpPort,int timeoutMillis){
  DatagramSocket socket=null;
  try {
    socket=new DatagramSocket();
    broadcast(udpPort,socket);
    socket.setSoTimeout(timeoutMillis);
    DatagramPacket packet=new DatagramPacket(new byte[0],0);
    try {
      socket.receive(packet);
    }
 catch (    SocketTimeoutException ex) {
      if (INFO)       info("kryonet","Host discovery timed out.");
      return null;
    }
    if (INFO)     info("kryonet","Discovered server: " + packet.getAddress());
    return packet.getAddress();
  }
 catch (  IOException ex) {
    if (ERROR)     error("kryonet","Host discovery failed.",ex);
    return null;
  }
 finally {
    if (socket != null)     socket.close();
  }
}

public InetAddress discoverHost ( int udpPort , int timeoutMillis ) { DatagramSocket socket = null ; try { socket = new DatagramSocket ( ) ; broadcast ( udpPort , socket ) ; socket . setSoTimeout ( timeoutMillis ) ; DatagramPacket packet = new DatagramPacket ( new byte [ 0 ] , 0 ) ; try { socket . receive ( packet ) ; } catch ( SocketTimeoutException ex ) { if ( INFO ) info ( "kryonet" , "Host discovery timed out." ) ; return null ; } if ( INFO ) info ( "kryonet" , "Discovered server: " + packet . getAddress ( ) ) ; return packet . getAddress ( ) ; } catch ( IOException ex ) { if ( ERROR ) error ( "kryonet" , "Host discovery failed." , ex ) ; return null ; } finally { if ( socket != null ) socket . close ( ) ; } }
broadcasts a udp message on the lan to discover any running servers . the address of the first server to respond is returned .
