|
|
An RPC server can be started from port monitors such as inetd(ADMN) and listen(SSC). These port monitors listen for requests for the services and spawn servers in response to those requests. The forked server process is passed file descriptor 0, on which the request has been accepted. For inetd, after the server has serviced the request, it may exit immediately or wait a given interval of time for another service request to come in.
The following routine can be used to create a service:
transp = svc_tli_create(0, nconf, NULL, 0, 0)nconf is the netconfig structure of the transport on which the request came in.
Because the port monitors have already registered the service with rpcbind, there is no need for the service to register itself. Nevertheless, it must call svc_reg:
svc_reg(transp, PROGNUM, VERSNUM, dispatch, NULL)The netconfig structure here is NULL.
For connection-oriented transports, the following routine provides a lower level interface:
transp = svc_fd_create(0, recvsize, sendsize);The file descriptor passed here is 0. The user may set the value of recvsize or sendsize to any appropriate buffer size. If they use a 0 in either case, a system default size will be chosen. This routine should be used by application servers that do not do any listening of their own, that is, servers that simply do their job and return.
The format of entries in /etc/inetd.conf for RPC services is as follows:
rpc_prog/vers socket_type rpcproto flags uid pathname argsHere:
mountd dgram rpc/udp wait root /usr/sbin/rpc.mountd rpc.mountFor more information, see inetd.conf(F).
We will assume here that the reader already knows the details of setting up the listener process and of using pmadm. The following shows how to use pmadm to add RPC services:
pmadm -a -p pm_tag -s svctag -i id -v ver \ -m "`nlsadmin -c command -D -R prog:vers`"Here -a means add a service, -p pm_tag specifies a tag associated with the port monitor providing access to the service, -s svctag is the server's identifying code, -i id is the /etc/passwd user ID assigned to service svctag, -v ver is the version number for the port monitor's database file and -m specifies the nlsadmin command for invoking the service. nlsadmin may have additional arguments. For example, to add version 1 of a remote program server named rusersd the pmadm command might be:
Here, the command is given root permissions, and is made available over TCP transports. If the service is to be a daemon process, the -c command must be replaced by a -p pipe where pipe is a FIFO or named STREAM.
After adding a service, the
listener
must be reinitialized before the service will be available.
This is accomplished by forcing the listener to re-read its database,
as follows (note that rpcbind must be running):
sacadm -x -p pmtag
For additional information, see the listen(SSC), pmadm(ADMN), and sacadm(ADMN) manual pages.