ONC+ Developer's Guide

Port Monitor Support

Port monitors such as inetd and listen can monitor network addresses for specified RPC services. When a request arrives for a particular service, the port monitor spawns a server process. After the call has been serviced, the server can exit. This technique conserves system resources. The main server function generated by rpcgen allows invocation by inetd. See "Using inetd" for details.

It may be useful for services to wait for a specified interval after satisfying a service request, in case another request follows. If there is no call in the specified time, the server exits, and some port monitors, like inetd, continue to monitor for the server. If a later request for the service occurs, the port monitor gives the request to a waiting server process (if any), rather than spawning a new process.


Note -

When monitoring for a server, some port monitors, like listen(), always spawn a new process in response to a service request. If a server is used with such a monitor, it should exit immediately on completion.


By default, services created using rpcgen wait for 120 seconds after servicing a request before exiting. The programmer can change the interval with the -K flag. In this example,

$ rpcgen -K 20 proto.x

the server waits for 20 seconds before exiting. To create a server that exits immediately, zero value can be used for the interval period:

$ rpcgen -K 0 proto.x.

To create a server that never exits, the value is -K -1.