protected boolean isCommandAvailable ( String command ) throws Throwable { Socket socket = null ; try { socket = new Socket ( host , port ) ; ObjectOutputStream output = new ObjectOutputStream ( socket . getOutputStream ( ) ) ; output . writeUTF ( "getcommand" ) ; output . writeInt ( 1 ) ; output . writeUTF ( command ) ; output . flush ( ) ; ObjectInputStream input = new ObjectInputStream ( socket . getInputStream ( ) ) ; Serializable result = ( Serializable ) input . readObject ( ) ; if ( result == null || ! ( result instanceof Throwable ) ) return true ; return false ; } finally { if ( socket != null ) { try { socket . close ( ) ; } catch ( IOException ioe ) { // Ignore } } } }
Is a command available