ONC+ Developer's Guide

Server Response to Broadcast Calls

When a procedure has been called through broadcast RPC and cannot provide a useful response, the server should send no reply to the client, thus reducing network traffic. To prevent the server from replying, a remote procedure can return NULL as its result. The server code generated by rpcgen detects this return and sends no reply.

The following code example is a procedure that replies only if it reaches an NFS server.

Example 3–23 NFS Server Response to Broadcast Calls

void *
	char notnull; /*only here so we can
						 *use its address

	if( access( "/etc/dfs/sharetab",
						F_OK ) < 0 ) {
		/* prevent RPC from replying */
		return( (void *) NULL );
	/* assign notnull a non-null value
 * then RPC sends a reply
	return( (void *) &notnull );

A procedure must return a non-NULL pointer when it is appropriate for RPC library routines to send a reply.

In the example, if the procedure reply_if_nfsserver() is defined to return nonvoid values, the return value &notnull should point to a static variable.