/** An example illustrating the implementation of a client in the " + " "); System.exit(-1); } // plenty of things can go wrong... try { brokerClient = new BrokerClient( "AdderClient", args[0], Integer.parseInt( args[1] ) ); brokerClient.connect(); } catch( ServerDownException e ) { System.err.println("Either the network is down, or there is no " + "broker running on the specified host and port" ); System.exit(-1); } catch( NumberFormatException e ) { System.err.println("One of the specified numbers was not considered " + "by Java to be a number." ); System.exit(-1); } catch( IOException e ) { System.err.println("An I/O error occurred: " + e.getMessage() ); System.exit(-1); } // do the actual function call try { Object result; result = brokerClient.callFunc( "Adder", "add " + args[2] + " " + args[3] + " " + args[4] ); if( !(result instanceof String ) ) System.err.println("Expected a string returned from the adder?"); else System.out.println("The sum is: " + ((String) result) ); } catch( BrokerException e ) { System.err.println("There was an error adding the numbers: '" + e.getMessage() + "'" ); brokerClient.disconnect(); System.exit(-1); } // Shut down the connection cleanly brokerClient.disconnect(); } }