The calls of the RPC intermediate layer are:
Routine
The transport mechanism is the User Datagram Protocol (UDP). The UDP transport mechanism handles only arguments and results that are less than 8K bytes in length. At this level, RPC does not allow timeout specifications, choice of transport, or process control, in case of errors. If you need this kind of control, consider the lowest layer of RPC.
With only these three RPC calls, you can write a powerful RPC-based network application. The sequence of events follows:
/* define remote program number and version */ #define RMTPROGNUM (u_long)0x3fffffffL #define RMTPROGVER (u_long)0x1 #define RMTPROCNUM (u_long)0x1 #include <stdio.h> #include <rpc\rpc.h>
main() { int *rmtprog(); /* register remote program with Portmapper */ registerrpc(RMTPROGNUM, RMTPROGVER, RMTPROCNUM, rmtprog, xdr_int, xdr_int); /* infinite loop, waits for RPC request from client */ svc_run(); printf("Error: svc_run should never reach this point \n"); exit(1); } int * rmtprog(inproc) /* remote program */ int *inproc; { int *outproc; ... /* Process request */ ... return (outproc); }
The registerrpc() call registers a C procedure rmtprog, which corresponds to a given RPC procedure number.
The registerrpc() call has six parameters:
/* define remote program number and version */ #define RMTPROGNUM (u_long)0x3fffffffL #define RMTPROGVER (u_long)0x1 #define RMTPROCNUM (u_long)0x1 #include <stdio.h> #include <rpc\rpc.h>
main() { int inproc=100, outproc, rstat; ... /* service request to host RPCSERVER_HOST */ if (rstat = callrpc("RPCSERVER_HOST", RMTPROGNUM, RMTPROGVER, RMTPROCNUM, xdr_int, (char *)&inproc, xdr_int, (char *)&outproc)!= 0) { clnt_perrno(rstat); /* Why callrpc() failed ? */ exit(1); } ... }
The callrpc() call has eight parameters: