Communicating local node using RPC
From Grid-Appliance Wiki
Contents |
Intorduction
Before staring this section, if you are not familiar with Brunet, you can refer to Brunet page first. This page shows a way to use IRpcHandler to send rpc call to the local brunet end point. A user can send xml rpc call using python script.At this example, rpc handler performs only server function. Thus, rpc hander receives rpc call from user and send result back to the user. More complicated rpc handler which performs server and client function will be discussed in the next section.
Compiling and running
Compile using existing library
You can download library and source code here. You should compile "HelloWorldRpcSHandler.cs" with Brunet.dll and BrunetApp.dll files.
For example, you can type "gmcs -r:Brunet.dll,BrunetApp.dll HelloWorldRpcSHandler.cs" in the colsole. You can also use mono compiler other than "gmcs".
Compile using your own brunet source code
If you want to use your brunet source code, you should create a folder under Applications directory, and copy HelloWorldRpcSHandler.cs and default.build files to the directory.
For example, create folder "HelloWorld" under the Brunet-Application directory (i.e.,brunet/src/Brunet/Applications/HelloWorld/), and copy two files to (brunet/src/Brunet/Applications/HelloWorld/). Run "nant" in the directory, and new executable will reference your own brunet source code.
If you have compile problem, you can download new version of brunet soucre code here
Running the application
1. Run HelloWorldRpcSHandler.exe with input argument local.config (Linux: mono HelloWorldNodeDataHandler local.config, Windows: HelloWorldNodeDataHandler.exe local.config)
2. Run python command shell. Type command as follows.
>>> import sys,xmlrpclib >>> rpc=xmlrpclib.Server("http://127.0.0.1:10000/xm.rem") >>> print rpc.localproxy("HwRpc.Test",xmlrpclib.Binary("Hello World")) Hello World >>>
- Here, you should be careful for the local host port number(127.0.0.1:10000). The port number should be same as port number of XmlRpcManager element at the local.config file (XmlRpcManager Port number).
- HelloWorldRpcSHandler sends the first input argument back as a result for rpc call. Thus, You should insert at least one argument for the rpc call to get correct result.
3. You can see the result at the application console as well as the python command shell.


