5 #include <xmlrpc-c/base.hpp>
6 #include <xmlrpc-c/registry.hpp>
7 #include <xmlrpc-c/server_abyss.hpp>
11 class sampleAddMethod : public xmlrpc_c::method {
14 // signature and help strings are documentation -- the client
15 // can query this information with a system.methodSignature and
16 // system.methodHelp RPC.
17 this->_signature = "i:ii";
18 // method's result and two arguments are integers
19 this->_help = "This method adds two integers together";
22 execute(xmlrpc_c::paramList const& paramList,
23 xmlrpc_c::value * const retvalP) {
25 int const addend(paramList.getInt(0));
26 int const adder(paramList.getInt(1));
28 paramList.verifyEnd(2);
30 *retvalP = xmlrpc_c::value_int(addend + adder);
38 const char ** const) {
41 xmlrpc_c::registry myRegistry;
43 xmlrpc_c::methodPtr const sampleAddMethodP(new sampleAddMethod);
45 myRegistry.addMethod("sample.add", sampleAddMethodP);
47 xmlrpc_c::serverAbyss myAbyssServer(
49 8080, // TCP port on which to listen
50 "/tmp/xmlrpc_log" // Log file
54 // xmlrpc_c::serverAbyss.run() never returns
56 } catch (exception const& e) {
57 cerr << "Something failed. " << e.what() << endl;