Intermediate Layer of RPC on the Server Side
Normally, the server registers each procedure, and then goes into an infinite loop waiting to
service requests. Because there is only a single procedure to register, the main body of the server
message would look like the following:
#include <stdio.h>
#include <rpc/rpc.h>
#include <utmp.h>
#include <rpcsvc/rusers.h>
char *nuser();
main()
{
registerrpc(RUSERSPROG, RUSERSVERS, RUSERSPROC_NUM,
nuser, xdr_void, xdr_u_long);
svc_run(); /* Never returns */
fprintf(stderr, "Error: svc_run returned!\n");
exit(1);
}
The registerrpc routine registers a C procedure as corresponding to a given RPC procedure number. The first three parameters, RUSERSPROG, RUSERSVERS, and RUSERSPROC_NUM, specify the program, version, and procedure numbers of the remote procedure to be registered. The nuser parameter is the name of the local procedure that implements the remote procedure, and the xdr_void and xdr_u_long parameters are the eXternal Data Representation (XDR) filters for the remote procedure's arguments and results, respectively.