public Set < Instance > runOnceOn ( InetAddress localhost ) throws IOException { logger . debug ( "Running query on {}" , localhost ) ; initialQuestion = new Question ( service , domain ) ; instances = Collections . synchronizedSet ( new HashSet <> ( ) ) ; try { Thread listener = null ; if ( localhost != TEST_SUITE_ADDRESS ) { openSocket ( localhost ) ; listener = listenForResponses ( ) ; while ( ! isServerIsListening ( ) ) { logger . debug ( "Server is not yet listening" ) ; } } ask ( initialQuestion ) ; if ( listener != null ) { try { listener . join ( ) ; } catch ( InterruptedException e ) { logger . error ( "InterruptedException while listening for mDNS responses: " , e ) ; } } } finally { closeSocket ( ) ; } return instances ; }
Synchronously runs the Query a single time .