question: protected void ping ( InetAddress address ) throws Exception { Socket socket = null ; int ping = 1 ; for ( ; ; ) { if ( isDebug ( ) ) { log ( "Trial #" + ping + "/" + getMaxPings ( ) + " - creating socket connected to " + address + " on port " + getPort ( ) ) ; } try { socket = new Socket ( address , getPort ( ) ) ; break ; } catch ( ConnectException ce ) { log ( "Trial #" + ping + "/" + getMaxPings ( ) + " - exception caught: " + ce . toString ( ) + " while creating socket connected to " + address + " on port " + getPort ( ) ) ; ping ++ ; if ( ping <= getMaxPings ( ) ) { log ( "Waiting " + getPingIntervalMilli ( ) + " milliseconds before retrying ..." ) ; Thread . sleep ( getPingIntervalMilli ( ) ) ; } else { break ; } } } if ( socket == null ) { throw new ConnectException ( "maxPings exceeded: " + getMaxPings ( ) + ". Giving up. The clamd daemon seems not to be running" ) ; } try { BufferedReader reader = new BufferedReader ( new InputStreamReader ( socket . getInputStream ( ) , "ASCII" ) ) ; PrintWriter writer = new PrintWriter ( new BufferedWriter ( new OutputStreamWriter ( socket . getOutputStream ( ) ) ) , true ) ; log ( "Sending: \"PING\" to " + address + " ..." ) ; writer . println ( "PING" ) ; writer . flush ( ) ; boolean pongReceived = false ; for ( ; ; ) { String answer = reader . readLine ( ) ; if ( answer != null ) { answer = answer . trim ( ) ; log ( "Received: \"" + answer + "\"" ) ; answer = answer . trim ( ) ; if ( answer . equals ( "PONG" ) ) { pongReceived = true ; } } else { break ; } } reader . close ( ) ; writer . close ( ) ; if ( ! pongReceived ) { throw new ConnectException ( "Bad answer from \"PING\" probe: expecting \"PONG\"" ) ; } } finally { socket . close ( ) ; } }
target:  Tries (and retries as specified up to 'getMaxPings()') to "ping" the specified CLAMD daemon to check if it is up and accepting requests.