Testing and Debugging the Application
The best way to test the RPC application is to run both the client and the server (the caller and callee) on the same machine. Assuming that you are in the directory where both the client and the server reside, start the server by entering the following command:
avg_svc &
The rpcinfo utility can be used to verify that the server is running. Typing the command
$ rpcinfo -p localhost
gives the following output:
program | vers | proto | port | |
100000 | 2 | tcp | 111 | portmapper |
100000 | 2 | udp | 111 | portmapper |
22855 | 1 | udp | 1221 | |
22855 | 1 | tcp | 1223 |
Note that 22855 is the program number of our application from avg.x and 1 is shown as the version number. Since 22855 is not a registered RPC application, the rightmost column is blank. If we add the following line to the /etc/rpc file
avg 22855
rpcinfo then gives the following output:
program vers proto port 100000 2 tcp 111 portmapper 100000 2 udp 111 portmapper 22855 1 udp 1221 avg 22855 1 tcp 1223 avg
To test the application, use the following command:
$ ravg localhost $RANDOM $RANDOM $RANDOM
The following values are returned:
value = 9.196000e+03 value = 2.871200e+04 value = 3.198900e+04 average = 2.329900e+04
Because the first argument to the command is the DNS name for the host running the server, localhost is used. If you have access to a remote host that allows RPC connections (ask the system administrator before you try), the server can be uploaded and run on the remote host, and the client can be run as before, replacing localhost with the DNS name or IP address of the host. If your remote host doesn't allow RPC connections, you may be able to run your client from there, replacing localhost with the DNS name or IP address of your local system.