The following code example shows the specification of a simple ping program.
/*
* Simple ping program
*/
program PING_PROG {
version PING_VERS_PINGBACK {
void
PINGPROC_NULL(void) = 0;
/*
* ping the caller, return the round-trip time
* in milliseconds. Return a minus one (-1) if
* operation times-out
*/
int
PINGPROC_PINGBACK(void) = 1;
/* void - above is an argument to the call */
} = 2;
/*
* Original version
*/
version PING_VERS_ORIG {
void
PINGPROC_NULL(void) = 0;
} = 1;
} = 200000;
const PING_VERS = 2; /* latest version */
The first version described is PING_VERS_PINGBACK with two procedures, PINGPROC_NULL and PINGPROC_PINGBACK.
PINGPROC_NULL takes no arguments and returns no results, but it is useful for such things as computing round-trip times from the client to the server and back again. By convention, procedure 0 of any RPC program should have the same semantics, and never require authentication.
The second procedure returns the amount of time in microseconds that the operation used.
The next version, PING_VERS_ORIG, is the original version of the protocol and does not contain the PINGPROC_PINGBACK procedure. It is useful for compatibility with old client programs.