Handling Broadcast on the Server Side
When a client calls a procedure through broadcast RPC, the server normally replies only if it can provide useful information to the client. This prevents flooding the network with useless replies.
To prevent the server from replying, a remote procedure can return
null as its result. The server code generated by the rpcgen compiler
detects this and does not send a reply. For example, the following
procedure replies only if it interprets itself to be a server:
void *
reply_if_nfsserver()
{
char notnull; /* just here so we can use its address */
if {access("/etc/exports", F_OK) < 0) {
return (NULL); /* prevent RPC from replying */
}
/*
*return non-null pointer so RPC will send out a reply
*/
return ((void *) ¬null);
}
If a procedure returns type void, the server must return a nonnull pointer in order for RPC to reply.