# phpman > man > rpc_svc_calls(3)

[RPC_SVC_CALLS(3)](https://www.chedong.com/phpMan.php/man/RPCSVCCALLS/3/markdown)         BSD Library Functions Manual         [RPC_SVC_CALLS(3)](https://www.chedong.com/phpMan.php/man/RPCSVCCALLS/3/markdown)

## NAME
     **svc**___**dg**___**enablecache**, **svc**___**exit**, **svc**___**fdset**, **svc**___**freeargs**, **svc**___**getargs**, **svc**___**getreq**___**common**,
     **svc**___**getreq**___**poll**, **svc**___**getreqset**, **svc**___**getrpccaller**, **svc**___**pollset**, **svc**___**run**, **svc**___**sendreply** — library
     routines for RPC servers

## SYNOPSIS
### #include <rpc/rpc.h>

     _int_
     **svc**___**dg**___**enablecache**(_SVCXPRT_ _*xprt_, _const_ _unsigned_ _cache_size_);

     _void_
     **svc**___**exit**(_void_);

     _bool_t_
     **svc**___**freeargs**(_const_ _SVCXPRT_ _*xprt_, _const_ _xdrproc_t_ _inproc_, _caddr_t_ _in_);

     _bool_t_
     **svc**___**getargs**(_const_ _SVCXPRT_ _*xprt_, _const_ _xdrproc_t_ _inproc_, _caddr_t_ _in_);

     _void_
     **svc**___**getreq**___**common**(_const_ _int_ _fd_);

     _void_
     **svc**___**getreq**___**poll**(_struct_ _pollfd_ _*pfdp_, _const_ _int_ _pollretval_);

     _void_
     **svc**___**getreqset**(_fd_set_ _*_ _rdfds_);

     _struct_ _netbuf_ _*_
     **svc**___**getrpccaller**(_const_ _SVCXPRT_ _*xprt_);

     _struct_ _cmsgcred_ _*_
     ____**svc**___**getcallercreds**(_const_ _SVCXPRT_ _*xprt_);

     _struct_ _pollfd_ _svc_pollset[FD_SETSIZE];_

     _void_
     **svc**___**run**(_void_);

     _bool_t_
     **svc**___**sendreply**(_SVCXPRT_ _*xprt_, _xdrproc_t_ _outproc_, _char_ _*out_);

## DESCRIPTION
     These routines are part of the RPC library which allows C language programs to make procedure
     calls on other machines across the network.

     These routines are associated with the server side of the RPC mechanism.  Some of them are
     called by the server side dispatch function, while others (such as **svc**___**run**()) are called when
     the server is initiated.

## Routines
     See [rpc(3)](https://www.chedong.com/phpMan.php/man/rpc/3/markdown) for the definition of the _SVCXPRT_ data structure.

     **svc**___**dg**___**enablecache**()    This function allocates a duplicate request cache for the service end‐
                             point _xprt_, large enough to hold _cache_size_ entries.  Once enabled,
                             there is no way to disable caching.  This routine returns 0 if space
                             necessary for a cache of the given size was successfully allocated, and
                             1 otherwise.

     **svc**___**exit**()              This function, when called by any of the RPC server procedure or other‐
                             wise, causes **svc**___**run**() to return.

                             As currently implemented, **svc**___**exit**() zeroes the _svc_fdset_ global vari‐
                             able.  If RPC server activity is to be resumed, services must be rereg‐
                             istered with the RPC library either through one of the
                             [rpc_svc_create(3)](https://www.chedong.com/phpMan.php/man/rpcsvccreate/3/markdown) functions, or using **xprt**___**register**().  The **svc**___**exit**()
                             function has global scope and ends all RPC server activity.

     _fd_set_ _svc_fdset_        A global variable reflecting the RPC server's read file descriptor bit
                             mask; it is suitable as an argument to the [select(2)](https://www.chedong.com/phpMan.php/man/select/2/markdown) system call.  This
                             is only of interest if service implementors do not call **svc**___**run**(), but
                             rather do their own asynchronous event processing.  This variable is
                             read-only (do not pass its address to [select(2)](https://www.chedong.com/phpMan.php/man/select/2/markdown)!), yet it may change
                             after calls to **svc**___**getreqset**() or any creation routines.

     **svc**___**freeargs**()          A function macro that frees any data allocated by the RPC/XDR system
                             when it decoded the arguments to a service procedure using
                             **svc**___**getargs**().  This routine returns TRUE if the results were success‐
                             fully freed, and FALSE otherwise.

     **svc**___**getargs**()           A function macro that decodes the arguments of an RPC request associ‐
                             ated with the RPC service transport handle _xprt_.  The _in_ argument is
                             the address where the arguments will be placed; _inproc_ is the XDR rou‐
                             tine used to decode the arguments.  This routine returns TRUE if decod‐
                             ing succeeds, and FALSE otherwise.

     **svc**___**getreq**___**common**()     This routine is called to handle a request on the given file descrip‐
                             tor.

     **svc**___**getreq**___**poll**()       This routine is only of interest if a service implementor does not call
                             **svc**___**run**(), but instead implements custom asynchronous event processing.
                             It is called when [poll(2)](https://www.chedong.com/phpMan.php/man/poll/2/markdown) has determined that an RPC request has ar‐
                             rived on some RPC file descriptors; _pollretval_ is the return value from
                             [poll(2)](https://www.chedong.com/phpMan.php/man/poll/2/markdown) and _pfdp_ is the array of _pollfd_ structures on which the [poll(2)](https://www.chedong.com/phpMan.php/man/poll/2/markdown)
                             was done.  It is assumed to be an array large enough to contain the
                             maximal number of descriptors allowed.

     **svc**___**getreqset**()         This routine is only of interest if a service implementor does not call
                             **svc**___**run**(), but instead implements custom asynchronous event processing.
                             It is called when [poll(2)](https://www.chedong.com/phpMan.php/man/poll/2/markdown) has determined that an RPC request has ar‐
                             rived on some RPC file descriptors; _rdfds_ is the resultant read file
                             descriptor bit mask.  The routine returns when all file descriptors as‐
                             sociated with the value of _rdfds_ have been serviced.

     **svc**___**getrpccaller**()      The approved way of getting the network address of the caller of a pro‐
                             cedure associated with the RPC service transport handle _xprt_.

     ____**svc**___**getcallercreds**()  _Warning_: this macro is specific to FreeBSD and thus not portable.  This
                             macro returns a pointer to a _cmsgcred_ structure, defined in
                             <_sys/socket.h_>, identifying the calling client.  This only works if the
                             client is calling the server over an AF_LOCAL socket.

     _struct_ _pollfd_ _svc_pollset[FD_SETSIZE]_;
                             _svc_pollset_ is an array of _pollfd_ structures derived from _svc_fdset[]_.
                             It is suitable as an argument to the [poll(2)](https://www.chedong.com/phpMan.php/man/poll/2/markdown) system call.  The deriva‐
                             tion of _svc_pollset_ from _svc_fdset_ is made in the current implementa‐
                             tion in **svc**___**run**().  Service implementors who do not call **svc**___**run**() and
                             who wish to use this array must perform this derivation themselves.

     **svc**___**run**()               This routine never returns.  It waits for RPC requests to arrive, and
                             calls the appropriate service procedure using **svc**___**getreq**___**poll**() when
                             one arrives.  This procedure is usually waiting for the [poll(2)](https://www.chedong.com/phpMan.php/man/poll/2/markdown) system
                             call to return.

     **svc**___**sendreply**()         Called by an RPC service's dispatch routine to send the results of a
                             remote procedure call.  The _xprt_ argument is the request's associated
                             transport handle; _outproc_ is the XDR routine which is used to encode
                             the results; and _out_ is the address of the results.  This routine re‐
                             turns TRUE if it succeeds, FALSE otherwise.

## AVAILABILITY
     These functions are part of libtirpc.

## SEE ALSO
     [poll(2)](https://www.chedong.com/phpMan.php/man/poll/2/markdown), [select(2)](https://www.chedong.com/phpMan.php/man/select/2/markdown), [rpc(3)](https://www.chedong.com/phpMan.php/man/rpc/3/markdown), [rpc_svc_create(3)](https://www.chedong.com/phpMan.php/man/rpcsvccreate/3/markdown), [rpc_svc_err(3)](https://www.chedong.com/phpMan.php/man/rpcsvcerr/3/markdown), [rpc_svc_reg(3)](https://www.chedong.com/phpMan.php/man/rpcsvcreg/3/markdown)

BSD                               May 3, 1993                              BSD
