RPC Language ping Program Example
This section explains the Remote Procedure Call language (RPCL) ping program example.
/*
* Simple ping program
*/
program PING_PROG {
/* Latest and greatest version */
version PING_VERS_PINGBACK {
void
PINGPROC_NULL(void) = 0;
/*
* Ping the caller, return the round-trip time
* (in microseconds). Returns -1 if the operation
* timed out.
*/
int
PINGPROC_PINGBACK(void) = 1;
} = 2;
/*
* Original version
*/
version PING_VERS_ORIG {
void
PINGPROC_NULL(void) = 0;
} = 1;
} = 1;
const PING_VERS = 2; /* latest version */
In this example, the first part of the ping program, PING_VERS_PINGBACK, consists of two procedures: PINGPROC_NULL and PINGPROC_PINGBACK. The PINGPROC_NULL procedure takes no arguments and returns no results. However, it is useful for computing round-trip times from the client to the server. By convention, procedure 0 of an RPC protocol should have the same semantics and require no kind of authentication. The second procedure, PINGPROC_PINGBACK, requests a reverse ping operation from the server. It returns the amount of time in microseconds that the operation used.
The second part, or original version of the ping program, PING_VERS_ORIG, does not contain the PINGPROC_PINGBACK procedure. The original version is useful for compatibility with older client programs. When the new ping program matures, this older version may be dropped from the protocol entirely.