|
|
When a procedure is known to have been called via broadcast RPC, and the called procedure determines that it cannot provide the client with a useful response, it is usually best for the server to send no reply back to the client. This reduces network traffic.
To prevent the server from replying, a remote procedure can return NULL as its result. The server code generated by rpcgen will detect this and not send out a reply.
This is an example of a procedure that replies only if it thinks it is an NFS server:
void * reply_if_nfsserver_1() { char notnull; /* just here so we can use its address */if (access("/etc/exports", F_OK) < 0) { return (NULL); /* prevent RPC from replying */ } /* * assign notnull a non-null value so RPC will send out a reply */ return ((void *)¬null); }