# phpman > man > RPC_SOC(3)

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

## NAME
     **rpc**___**soc**, **auth**___**destroy**, **authnone**___**create**, **authunix**___**create**, **authunix**___**create**___**default**, **callrpc**,
     **clnt**___**broadcast**, **clnt**___**call**, **clnt**___**control**, **clnt**___**create**, **clnt**___**destroy**, **clnt**___**freeres**, **clnt**___**geterr**,
     **clnt**___**pcreateerror**, **clnt**___**perrno**, **clnt**___**perror**, **clnt**___**spcreateerror**, **clnt**___**sperrno**, **clnt**___**sperror**,
     **clntraw**___**create**, **clnttcp**___**create**, **clntudp**___**bufcreate**, **clntudp**___**create**, **clntunix**___**create**,
     **get**___**myaddress**, **pmap**___**getmaps**, **pmap**___**getport**, **pmap**___**rmtcall**, **pmap**___**set**, **pmap**___**unset**, **registerrpc**,
     **rpc**___**createerr**, **svc**___**destroy**, **svc**___**fds**, **svc**___**fdset**, **svc**___**getargs**, **svc**___**getcaller**, **svc**___**getreq**,
     **svc**___**getreqset**, **svc**___**register**, **svc**___**run**, **svc**___**sendreply**, **svc**___**unregister**, **svcerr**___**auth**,
     **svcerr**___**decode**, **svcerr**___**noproc**, **svcerr**___**noprog**, **svcerr**___**progvers**, **svcerr**___**systemerr**,
     **svcerr**___**weakauth**, **svcfd**___**create**, **svcunixfd**___**create**, **svcraw**___**create**, **svcunix**___**create**,
     **xdr**___**accepted**___**reply**, **xdr**___**authunix**___**parms**, **xdr**___**callhdr**, **xdr**___**callmsg**, **xdr**___**opaque**___**auth**, **xdr**___**pmap**,
     **xdr**___**pmaplist**, **xdr**___**rejected**___**reply**, **xdr**___**replymsg**, **xprt**___**register**, **xprt**___**unregister** — library rou‐
     tines for remote procedure calls

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

     See _DESCRIPTION_ for function declarations.

## DESCRIPTION
     **The** **svc**___*****() **and** **clnt**___*****() **functions** **described** **in** **this** **page** **are** **the** **old,** **TS-RPC** **interface** **to** **the**
### XDR and RPC library, and exist for backward compatibility.  The new interface is described in
     **the** **pages** **referenced** **from** [rpc(**3**)](https://www.chedong.com/phpMan.php/man/rpc/3/markdown)**.**

     These routines allow C programs to make procedure calls on other machines across the network.
     First, the client calls a procedure to send a data packet to the server.  Upon receipt of the
     packet, the server calls a dispatch routine to perform the requested service, and then sends
     back a reply.  Finally, the procedure call returns to the client.

     Routines that are used for Secure RPC (DES authentication) are described in [rpc_secure(3)](https://www.chedong.com/phpMan.php/man/rpcsecure/3/markdown).  Se‐
     cure RPC can be used only if DES encryption is available.

     _void_
     **auth**___**destroy**(_AUTH_ _*auth_)

             A macro that destroys the authentication information associated with _auth_.  Destruction
             usually involves deallocation of private data structures.  The use of _auth_ is undefined
             after calling **auth**___**destroy**().

     _AUTH_ _*_
     **authnone**___**create**()

             Create and return an RPC authentication handle that passes nonusable authentication in‐
             formation with each remote procedure call.  This is the default authentication used by
             RPC.

     _AUTH_ _*_
     **authunix**___**create**(_char_ _*host_, _int_ _uid_, _int_ _gid_, _int_ _len_, _int_ _*aup_gids_)

             Create and return an RPC authentication handle that contains UNIX authentication infor‐
             mation.  The _host_ argument is the name of the machine on which the information was cre‐
             ated; _uid_ is the user's user ID; _gid_ is the user's current group ID; _len_ and _aup_gids_
             refer to a counted array of groups to which the user belongs.  It is easy to imperson‐
             ate a user.

     _AUTH_ _*_
     **authunix**___**create**___**default**()

             Calls **authunix**___**create**() with the appropriate arguments.

     _int_ **callrpc**(_char_ _*host_, _u_long_ _prognum_, _u_long_ _versnum_, _u_long_ _procnum_, _xdrproc_t_ _inproc_,
             _void_ _*in_, _xdrproc_t_ _outproc_, _void_ _*out_)

             Call the remote procedure associated with _prognum_, _versnum_, and _procnum_ on the machine
             _host_.  The _in_ argument is the address of the procedure's argument(s), and _out_ is the
             address of where to place the result(s); _inproc_ is used to encode the procedure's argu‐
             ments, and _outproc_ is used to decode the procedure's results.  This routine returns
             zero if it succeeds, or the value of _enum_ _clnt_stat_ cast to an integer if it fails.
             The routine **clnt**___**perrno**() is handy for translating failure statuses into messages.

             Warning: calling remote procedures with this routine uses UDP/IP as a transport; see
             **clntudp**___**create**() for restrictions.  You do not have control of timeouts or authentica‐
             tion using this routine.

     _enum_ _clnt_stat_
     **clnt**___**broadcast**(_u_long_ _prognum_, _u_long_ _versnum_, _u_long_ _procnum_, _xdrproc_t_ _inproc_, _char_ _*in_,
             _xdrproc_t_ _outproc_, _char_ _*out_, _bool_t_ _(*eachresult)(caddr_t,_ _struct_ _sockaddr_in_ _*)_)

             Like **callrpc**(), except the call message is broadcast to all locally connected broadcast
             nets.  Each time it receives a response, this routine calls **eachresult**(), whose form
             is:

                   _bool_t_ **eachresult**(_caddr_t_ _out_, _struct_ _sockaddr_in_ _*addr_)

             where _out_ is the same as _out_ passed to **clnt**___**broadcast**(), except that the remote proce‐
             dure's output is decoded there; _addr_ points to the address of the machine that sent the
             results.  If **eachresult**() returns zero, **clnt**___**broadcast**() waits for more replies; other‐
             wise it returns with appropriate status.

             Warning: broadcast sockets are limited in size to the maximum transfer unit of the data
             link.  For ethernet, this value is 1500 bytes.

     _enum_ _clnt_stat_
     **clnt**___**call**(_CLIENT_ _*clnt_, _u_long_ _procnum_, _xdrproc_t_ _inproc_, _char_ _*in_, _xdrproc_t_ _outproc_,
             _char_ _*out_, _struct_ _timeval_ _tout_)

             A macro that calls the remote procedure _procnum_ associated with the client handle,
             _clnt_, which is obtained with an RPC client creation routine such as **clnt**___**create**().  The
             _in_ argument is the address of the procedure's argument(s), and _out_ is the address of
             where to place the result(s); _inproc_ is used to encode the procedure's arguments, and
             _outproc_ is used to decode the procedure's results; _tout_ is the time allowed for results
             to come back.

     _void_ **clnt**___**destroy**(_CLIENT_ _*clnt_)

             A macro that destroys the client's RPC handle.  Destruction usually involves dealloca‐
             tion of private data structures, including _clnt_ itself.  Use of _clnt_ is undefined after
             calling **clnt**___**destroy**().  If the RPC library opened the associated socket, it will close
             it also.  Otherwise, the socket remains open.

     _CLIENT_ _*_
     **clnt**___**create**(_char_ _*host_, _u_long_ _prog_, _u_long_ _vers_, _char_ _*proto_)

             Generic client creation routine.  The _host_ argument identifies the name of the remote
             host where the server is located.  The _proto_ argument indicates which kind of transport
             protocol to use.  The currently supported values for this field are "udp" and "tcp".
             Default timeouts are set, but can be modified using **clnt**___**control**().

             Warning: Using UDP has its shortcomings.  Since UDP-based RPC messages can only hold up
             to 8 Kbytes of encoded data, this transport cannot be used for procedures that take
             large arguments or return huge results.

     _bool_t_
     **clnt**___**control**(_CLIENT_ _*cl_, _u_int_ _req_, _char_ _*info_)

             A macro used to change or retrieve various information about a client object.  The _req_
             argument indicates the type of operation, and _info_ is a pointer to the information.
             For both UDP and TCP, the supported values of _req_ and their argument types and what
             they do are:

             CLSET_TIMEOUT          _struct_ _timeval_        set total timeout
             CLGET_TIMEOUT          _struct_ _timeval_        get total timeout

             Note: if you set the timeout using **clnt**___**control**(), the timeout argument passed to
             **clnt**___**call**() will be ignored in all future calls.

             CLGET_SERVER_ADDR      _struct_ _sockaddr_in_    get server's address

             The following operations are valid for UDP only:

             CLSET_RETRY_TIMEOUT    _struct_ _timeval_        set the retry timeout
             CLGET_RETRY_TIMEOUT    _struct_ _timeval_        get the retry timeout

             The retry timeout is the time that UDP RPC waits for the server to reply before re‐
             transmitting the request.

     _bool_t_ **clnt**___**freeres**(_CLIENT_ _*clnt_, _xdrproc_t_ _outproc_, _char_ _*out_)

             A macro that frees any data allocated by the RPC/XDR system when it decoded the results
             of an RPC call.  The _out_ argument is the address of the results, and _outproc_ is the XDR
             routine describing the results.  This routine returns one if the results were success‐
             fully freed, and zero otherwise.

     _void_
     **clnt**___**geterr**(_CLIENT_ _*clnt_, _struct_ _rpc_err_ _*errp_)

             A macro that copies the error structure out of the client handle to the structure at
             address _errp_.

     _void_
     **clnt**___**pcreateerror**(_char_ _*s_)

             prints a message to standard error indicating why a client RPC handle could not be cre‐
             ated.  The message is prepended with string _s_ and a colon.  A newline is appended at
             the end of the message.  Used when a **clnt**___**create**(), **clntraw**___**create**(), **clnttcp**___**create**(),
             or **clntudp**___**create**() call fails.

     _void_
     **clnt**___**perrno**(_enum_ _clnt_stat_ _stat_)

             Print a message to standard error corresponding to the condition indicated by _stat_.  A
             newline is appended at the end of the message.  Used after **callrpc**().

     _void_ **clnt**___**perror**(_CLIENT_ _*clnt_, _char_ _*s_)

             Print a message to standard error indicating why an RPC call failed; _clnt_ is the handle
             used to do the call.  The message is prepended with string _s_ and a colon.  A newline is
             appended at the end of the message.  Used after **clnt**___**call**().

     _char_ _*_
     **clnt**___**spcreateerror**(_char_ _*s_)

             Like **clnt**___**pcreateerror**(), except that it returns a string instead of printing to the
             standard error.

             Bugs: returns pointer to static data that is overwritten on each call.

     _char_ _*_
     **clnt**___**sperrno**(_enum_ _clnt_stat_ _stat_)

             Take the same arguments as **clnt**___**perrno**(), but instead of sending a message to the stan‐
             dard error indicating why an RPC call failed, return a pointer to a string which con‐
             tains the message.

             The **clnt**___**sperrno**() function is used instead of **clnt**___**perrno**() if the program does not
             have a standard error (as a program running as a server quite likely does not), or if
             the programmer does not want the message to be output with **printf**(), or if a message
             format different from that supported by **clnt**___**perrno**() is to be used.

             Note: unlike **clnt**___**sperror**() and **clnt**___**spcreateerror**(), **clnt**___**sperrno**() returns pointer to
             static data, but the result will not get overwritten on each call.

     _char_ _*_
     **clnt**___**sperror**(_CLIENT_ _*rpch_, _char_ _*s_)

             Like **clnt**___**perror**(), except that (like **clnt**___**sperrno**()) it returns a string instead of
             printing to standard error.

             Bugs: returns pointer to static data that is overwritten on each call.

     _CLIENT_ _*_
     **clntraw**___**create**(_u_long_ _prognum_, _u_long_ _versnum_)

             This routine creates a toy RPC client for the remote program _prognum_, version _versnum_.
             The transport used to pass messages to the service is actually a buffer within the
             process's address space, so the corresponding RPC server should live in the same ad‐
             dress space; see **svcraw**___**create**().  This allows simulation of RPC and acquisition of RPC
             overheads, such as round trip times, without any kernel interference.  This routine re‐
             turns NULL if it fails.

     _CLIENT_ _*_
     **clnttcp**___**create**(_struct_ _sockaddr_in_ _*addr_, _u_long_ _prognum_, _u_long_ _versnum_, _int_ _*sockp_,
             _u_int_ _sendsz_, _u_int_ _recvsz_)

             This routine creates an RPC client for the remote program _prognum_, version _versnum_; the
             client uses TCP/IP as a transport.  The remote program is located at Internet address
             _addr_.  If _addr->sin_port_ is zero, then it is set to the actual port that the remote
             program is listening on (the remote [rpcbind(8)](https://www.chedong.com/phpMan.php/man/rpcbind/8/markdown) service is consulted for this informa‐
             tion).  The _sockp_ argument is a socket; if it is RPC_ANYSOCK, then this routine opens a
             new one and sets _sockp_.  Since TCP-based RPC uses buffered I/O, the user may specify
             the size of the send and receive buffers with the _sendsz_ and _recvsz_ arguments; values
             of zero choose suitable defaults.  This routine returns NULL if it fails.

     _CLIENT_ _*_
     **clntudp**___**create**(_struct_ _sockaddr_in_ _*addr_, _u_long_ _prognum_, _u_long_ _versnum_, _struct_ _timeval_ _wait_,
             _int_ _*sockp_)

             This routine creates an RPC client for the remote program _prognum_, version _versnum_; the
             client uses UDP/IP as a transport.  The remote program is located at Internet address
             _addr_.  If _addr->sin_port_ is zero, then it is set to actual port that the remote program
             is listening on (the remote [rpcbind(8)](https://www.chedong.com/phpMan.php/man/rpcbind/8/markdown) service is consulted for this information).  The
             _sockp_ argument is a socket; if it is RPC_ANYSOCK, then this routine opens a new one and
             sets _sockp_.  The UDP transport resends the call message in intervals of _wait_ time until
             a response is received or until the call times out.  The total time for the call to
             time out is specified by **clnt**___**call**().

             Warning: since UDP-based RPC messages can only hold up to 8 Kbytes of encoded data,
             this transport cannot be used for procedures that take large arguments or return huge
             results.

     _CLIENT_ _*_
     **clntudp**___**bufcreate**(_struct_ _sockaddr_in_ _*addr_, _u_long_ _prognum_, _u_long_ _versnum_,
             _struct_ _timeval_ _wait_, _int_ _*sockp_, _unsigned_ _int_ _sendsize_, _unsigned_ _int_ _recosize_)

             This routine creates an RPC client for the remote program _prognum_, on _versnum_; the
             client uses UDP/IP as a transport.  The remote program is located at Internet address
             _addr_.  If _addr->sin_port_ is zero, then it is set to actual port that the remote program
             is listening on (the remote [rpcbind(8)](https://www.chedong.com/phpMan.php/man/rpcbind/8/markdown) service is consulted for this information).  The
             _sockp_ argument is a socket; if it is RPC_ANYSOCK, then this routine opens a new one and
             sets _sockp_.  The UDP transport resends the call message in intervals of _wait_ time until
             a response is received or until the call times out.  The total time for the call to
             time out is specified by **clnt**___**call**().

             This allows the user to specify the maximum packet size for sending and receiving
             UDP-based RPC messages.

     _CLIENT_ _*_
     **clntunix**___**create**(_struct_ _sockaddr_un_ _*raddr_, _u_long_ _prognum_, _u_long_ _versnum_, _int_ _*sockp_,
             _u_int_ _sendsz_, _u_int_ _recvsz_)

             This routine creates an RPC client for the local program _prognum_, version _versnum_; the
             client uses UNIX-domain sockets as a transport.  The local program is located at the
             _*raddr_.  The _sockp_ argument is a socket; if it is RPC_ANYSOCK, then this routine opens
             a new one and sets _sockp_.  Since UNIX-based RPC uses buffered I/O, the user may specify
             the size of the send and receive buffers with the _sendsz_ and _recvsz_ arguments; values
             of zero choose suitable defaults.  This routine returns NULL if it fails.

     _int_
     **get**___**myaddress**(_struct_ _sockaddr_in_ _*addr_)

             Stuff the machine's IP address into _addr_, without consulting the library routines that
             deal with _/etc/hosts_.  The port number is always set to **htons**(_PMAPPORT_).  Returns zero
             on success, non-zero on failure.

     _struct_ _pmaplist_ _*_
     **pmap**___**getmaps**(_struct_ _sockaddr_in_ _*addr_)

             A user interface to the [rpcbind(8)](https://www.chedong.com/phpMan.php/man/rpcbind/8/markdown) service, which returns a list of the current RPC
             program-to-port mappings on the host located at IP address _addr_.  This routine can re‐
             turn NULL.  The command “**rpcinfo** **-p**” uses this routine.

     _u_short_
     **pmap**___**getport**(_struct_ _sockaddr_in_ _*addr_, _u_long_ _prognum_, _u_long_ _versnum_, _u_long_ _protocol_)

             A user interface to the [rpcbind(8)](https://www.chedong.com/phpMan.php/man/rpcbind/8/markdown) service, which returns the port number on which
             waits a service that supports program number _prognum_, version _versnum_, and speaks the
             transport protocol associated with _protocol_.  The value of _protocol_ is most likely
             IPPROTO_UDP or IPPROTO_TCP.  A return value of zero means that the mapping does not ex‐
             ist or that the RPC system failed to contact the remote [rpcbind(8)](https://www.chedong.com/phpMan.php/man/rpcbind/8/markdown) service.  In the
             latter case, the global variable _rpc_createerr_ contains the RPC status.

     _enum_ _clnt_stat_
     **pmap**___**rmtcall**(_struct_ _sockaddr_in_ _*addr_, _u_long_ _prognum_, _u_long_ _versnum_, _u_long_ _procnum_,
             _xdrproc_t_ _inproc_, _char_ _*in_, _xdrproc_t_ _outproc_, _char_ _*out_, _struct_ _timeval_ _tout_,
             _u_long_ _*portp_)

             A user interface to the [rpcbind(8)](https://www.chedong.com/phpMan.php/man/rpcbind/8/markdown) service, which instructs [rpcbind(8)](https://www.chedong.com/phpMan.php/man/rpcbind/8/markdown) on the host at
             IP address _addr_ to make an RPC call on your behalf to a procedure on that host.  The
             _portp_ argument will be modified to the program's port number if the procedure succeeds.
             The definitions of other arguments are discussed in **callrpc**() and **clnt**___**call**().  This
             procedure should be used for a “ping” and nothing else.  See also **clnt**___**broadcast**().

     _bool_t_ **pmap**___**set**(_u_long_ _prognum_, _u_long_ _versnum_, _u_long_ _protocol_, _u_short_ _port_)

             A user interface to the [rpcbind(8)](https://www.chedong.com/phpMan.php/man/rpcbind/8/markdown) service, which establishes a mapping between the
             triple (_prognum_, _versnum_, _protocol_) and _port_ on the machine's [rpcbind(8)](https://www.chedong.com/phpMan.php/man/rpcbind/8/markdown) service.  The
             value of _protocol_ is most likely IPPROTO_UDP or IPPROTO_TCP.  This routine returns one
             if it succeeds, zero otherwise.  Automatically done by **svc**___**register**().

     _bool_t_ **pmap**___**unset**(_u_long_ _prognum_, _u_long_ _versnum_)

             A user interface to the [rpcbind(8)](https://www.chedong.com/phpMan.php/man/rpcbind/8/markdown) service, which destroys all mapping between the
             triple (_prognum_, _versnum_, _*_) and _ports_ on the machine's [rpcbind(8)](https://www.chedong.com/phpMan.php/man/rpcbind/8/markdown) service.  This rou‐
             tine returns one if it succeeds, zero otherwise.

     _bool_t_ **registerrpc**(_u_long_ _prognum_, _u_long_ _versnum_, _u_long_ _procnum_, _char_ _*(*procname)(void)_,
             _xdrproc_t_ _inproc_, _xdrproc_t_ _outproc_)

             Register procedure _procname_ with the RPC service package.  If a request arrives for
             program _prognum_, version _versnum_, and procedure _procnum_, _procname_ is called with a
             pointer to its argument(s); _progname_ should return a pointer to its static result(s);
             _inproc_ is used to decode the arguments while _outproc_ is used to encode the results.
             This routine returns zero if the registration succeeded, -1 otherwise.

             Warning: remote procedures registered in this form are accessed using the UDP/IP trans‐
             port; see **svcudp**___**create**() for restrictions.

     _struct_ _rpc_createerr_ _rpc_createerr_;

             A global variable whose value is set by any RPC client creation routine that does not
             succeed.  Use the routine **clnt**___**pcreateerror**() to print the reason why.

     _bool_t_ **svc**___**destroy**(_SVCXPRT_ _*_ _xprt_)

             A macro that destroys the RPC service transport handle, _xprt_.  Destruction usually in‐
             volves deallocation of private data structures, including _xprt_ itself.  Use of _xprt_ is
             undefined after calling this routine.

     _fd_set_ _svc_fdset_;

             A global variable reflecting the RPC service side's read file descriptor bit mask; it
             is suitable as a template argument to the [select(2)](https://www.chedong.com/phpMan.php/man/select/2/markdown) system call.  This is only of in‐
             terest if a service implementor does not call **svc**___**run**(), but rather does his own asyn‐
             chronous 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.
             As well, note that if the process has descriptor limits which are extended beyond
             FD_SETSIZE, this variable will only be usable for the first FD_SETSIZE descriptors.

     _int_ _svc_fds_;

             Similar to _svc_fdset_, but limited to 32 descriptors.  This interface is obsoleted by
             _svc_fdset_.

     _bool_t_ **svc**___**freeargs**(_SVCXPRT_ _*xprt_, _xdrproc_t_ _inproc_, _char_ _*in_)

             A macro that frees any data allocated by the RPC/XDR system when it decoded the argu‐
             ments to a service procedure using **svc**___**getargs**().  This routine returns 1 if the re‐
             sults were successfully freed, and zero otherwise.

     _bool_t_ **svc**___**getargs**(_SVCXPRT_ _*xprt_, _xdrproc_t_ _inproc_, _char_ _*in_)

             A macro that decodes the arguments of an RPC request associated with the RPC service
             transport handle, _xprt_.  The _in_ argument is the address where the arguments will be
             placed; _inproc_ is the XDR routine used to decode the arguments.  This routine returns
             one if decoding succeeds, and zero otherwise.

     _struct_ _sockaddr_in_ _*_
     **svc**___**getcaller**(_SVCXPRT_ _*xprt_)

             The approved way of getting the network address of the caller of a procedure associated
             with the RPC service transport handle, _xprt_.

     _void_ **svc**___**getreqset**(_fd_set_ _*rdfds_)

             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 the
             [select(2)](https://www.chedong.com/phpMan.php/man/select/2/markdown) system call has determined that an RPC request has arrived on some RPC
             socket(s); _rdfds_ is the resultant read file descriptor bit mask.  The routine returns
             when all sockets associated with the value of _rdfds_ have been serviced.

     _void_ **svc**___**getreq**(_int_ _rdfds_)

             Similar to **svc**___**getreqset**(), but limited to 32 descriptors.  This interface is obsoleted
             by **svc**___**getreqset**().

     _bool_t_ **svc**___**register**(_SVCXPRT_ _*xprt_, _u_long_ _prognum_, _u_long_ _versnum_,
             _void_ _(*dispatch)(struct_ _svc_req_ _*,_ _SVCXPRT_ _*)_, _int_ _protocol_)

             Associates _prognum_ and _versnum_ with the service dispatch procedure, **dispatch**().  If
             _protocol_ is zero, the service is not registered with the [rpcbind(8)](https://www.chedong.com/phpMan.php/man/rpcbind/8/markdown) service.  If
             _protocol_ is non-zero, then a mapping of the triple (_prognum_, _versnum_, _protocol_) to
             _xprt->xp_port_ is established with the local [rpcbind(8)](https://www.chedong.com/phpMan.php/man/rpcbind/8/markdown) service (generally _protocol_ is
             zero, IPPROTO_UDP or IPPROTO_TCP).  The procedure **dispatch**() has the following form:

                   _bool_t_ **dispatch**(_struct_ _svc_req_ _*request_, _SVCXPRT_ _*xprt_)

             The **svc**___**register**() routine returns one if it succeeds, and zero otherwise.

     **svc**___**run**()

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

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

             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 returns one if it succeeds, zero otherwise.

     _void_
     **svc**___**unregister**(_u_long_ _prognum_, _u_long_ _versnum_)

             Remove all mapping of the double (_prognum_, _versnum_) to dispatch routines, and of the
             triple (_prognum_, _versnum_, _*_) to port number.

     _void_
     **svcerr**___**auth**(_SVCXPRT_ _*xprt_, _enum_ _auth_stat_ _why_)

             Called by a service dispatch routine that refuses to perform a remote procedure call
             due to an authentication error.

     _void_
     **svcerr**___**decode**(_SVCXPRT_ _*xprt_)

             Called by a service dispatch routine that cannot successfully decode its arguments.
             See also **svc**___**getargs**().

     _void_
     **svcerr**___**noproc**(_SVCXPRT_ _*xprt_)

             Called by a service dispatch routine that does not implement the procedure number that
             the caller requests.

     _void_
     **svcerr**___**noprog**(_SVCXPRT_ _*xprt_)

             Called when the desired program is not registered with the RPC package.  Service imple‐
             mentors usually do not need this routine.

     _void_
     **svcerr**___**progvers**(_SVCXPRT_ _*xprt_, _u_long_ _low_vers_, _u_long_ _high_vers_)

             Called when the desired version of a program is not registered with the RPC package.
             Service implementors usually do not need this routine.

     _void_
     **svcerr**___**systemerr**(_SVCXPRT_ _*xprt_)

             Called by a service dispatch routine when it detects a system error not covered by any
             particular protocol.  For example, if a service can no longer allocate storage, it may
             call this routine.

     _void_
     **svcerr**___**weakauth**(_SVCXPRT_ _*xprt_)

             Called by a service dispatch routine that refuses to perform a remote procedure call
             due to insufficient authentication arguments.  The routine calls **svcerr**___**auth**(_xprt_,
             _AUTH_TOOWEAK_).

     _SVCXPRT_ _*_
     **svcraw**___**create**(_void_)

             This routine creates a toy RPC service transport, to which it returns a pointer.  The
             transport is really a buffer within the process's address space, so the corresponding
             RPC client should live in the same address space; see **clntraw**___**create**().  This routine
             allows simulation of RPC and acquisition of RPC overheads (such as round trip times),
             without any kernel interference.  This routine returns NULL if it fails.

     _SVCXPRT_ _*_
     **svctcp**___**create**(_int_ _sock_, _u_int_ _send_buf_size_, _u_int_ _recv_buf_size_)

             This routine creates a TCP/IP-based RPC service transport, to which it returns a
             pointer.  The transport is associated with the socket _sock_, which may be RPC_ANYSOCK,
             in which case a new socket is created.  If the socket is not bound to a local TCP port,
             then this routine binds it to an arbitrary port.  Upon completion, _xprt->xp_fd_ is the
             transport's socket descriptor, and _xprt->xp_port_ is the transport's port number.  This
             routine returns NULL if it fails.  Since TCP-based RPC uses buffered I/O, users may
             specify the size of buffers; values of zero choose suitable defaults.

     _SVCXPRT_ _*_
     **svcunix**___**create**(_int_ _sock_, _u_int_ _send_buf_size_, _u_int_ _recv_buf_size_, _char_ _*path_)

             This routine creates a UNIX-based RPC service transport, to which it returns a pointer.
             The transport is associated with the socket _sock_, which may be RPC_ANYSOCK, in which
             case a new socket is created.  The _*path_ argument is a variable-length file system
             pathname of at most 104 characters.  This file is _not_ removed when the socket is
             closed.  The [unlink(2)](https://www.chedong.com/phpMan.php/man/unlink/2/markdown) system call must be used to remove the file.  Upon completion,
             _xprt->xp_fd_ is the transport's socket descriptor.  This routine returns NULL if it
             fails.  Since UNIX-based RPC uses buffered I/O, users may specify the size of buffers;
             values of zero choose suitable defaults.

     _SVCXPRT_ _*_
     **svcunixfd**___**create**(_int_ _fd_, _u_int_ _sendsize_, _u_int_ _recvsize_)

             Create a service on top of any open descriptor.  The _sendsize_ and _recvsize_ arguments
             indicate sizes for the send and receive buffers.  If they are zero, a reasonable de‐
             fault is chosen.

     _SVCXPRT_ _*_
     **svcfd**___**create**(_int_ _fd_, _u_int_ _sendsize_, _u_int_ _recvsize_)

             Create a service on top of any open descriptor.  Typically, this descriptor is a con‐
             nected socket for a stream protocol such as TCP.  The _sendsize_ and _recvsize_ arguments
             indicate sizes for the send and receive buffers.  If they are zero, a reasonable de‐
             fault is chosen.

     _SVCXPRT_ _*_
     **svcudp**___**bufcreate**(_int_ _sock_, _u_int_ _sendsize_, _u_int_ _recvsize_)

             This routine creates a UDP/IP-based RPC service transport, to which it returns a
             pointer.  The transport is associated with the socket _sock_, which may be RPC_ANYSOCK,
             in which case a new socket is created.  If the socket is not bound to a local UDP port,
             then this routine binds it to an arbitrary port.  Upon completion, _xprt->xp_fd_ is the
             transport's socket descriptor, and _xprt->xp_port_ is the transport's port number.  This
             routine returns NULL if it fails.

             This allows the user to specify the maximum packet size for sending and receiving
             UDP-based RPC messages.

     _bool_t_ **xdr**___**accepted**___**reply**(_XDR_ _*xdrs_, _struct_ _accepted_reply_ _*ar_)

             Used for encoding RPC reply messages.  This routine is useful for users who wish to
             generate RPC-style messages without using the RPC package.

     _bool_t_ **xdr**___**authunix**___**parms**(_XDR_ _*xdrs_, _struct_ _authunix_parms_ _*aupp_)

             Used for describing UNIX credentials.  This routine is useful for users who wish to
             generate these credentials without using the RPC authentication package.

     _void_
     _bool_t_ **xdr**___**callhdr**(_XDR_ _*xdrs_, _struct_ _rpc_msg_ _*chdr_)

             Used for describing RPC call header messages.  This routine is useful for users who
             wish to generate RPC-style messages without using the RPC package.

     _bool_t_ **xdr**___**callmsg**(_XDR_ _*xdrs_, _struct_ _rpc_msg_ _*cmsg_)

             Used for describing RPC call messages.  This routine is useful for users who wish to
             generate RPC-style messages without using the RPC package.

     _bool_t_ **xdr**___**opaque**___**auth**(_XDR_ _*xdrs_, _struct_ _opaque_auth_ _*ap_)

             Used for describing RPC authentication information messages.  This routine is useful
             for users who wish to generate RPC-style messages without using the RPC package.

     _struct_ _pmap_;
     _bool_t_ **xdr**___**pmap**(_XDR_ _*xdrs_, _struct_ _pmap_ _*regs_)

             Used for describing arguments to various [rpcbind(8)](https://www.chedong.com/phpMan.php/man/rpcbind/8/markdown) procedures, externally.  This rou‐
             tine is useful for users who wish to generate these arguments without using the
             **pmap**___*****() interface.

     _bool_t_ **xdr**___**pmaplist**(_XDR_ _*xdrs_, _struct_ _pmaplist_ _**rp_)

             Used for describing a list of port mappings, externally.  This routine is useful for
             users who wish to generate these arguments without using the **pmap**___*****() interface.

     _bool_t_ **xdr**___**rejected**___**reply**(_XDR_ _*xdrs_, _struct_ _rejected_reply_ _*rr_)

             Used for describing RPC reply messages.  This routine is useful for users who wish to
             generate RPC-style messages without using the RPC package.

     _bool_t_ **xdr**___**replymsg**(_XDR_ _*xdrs_, _struct_ _rpc_msg_ _*rmsg_)

             Used for describing RPC reply messages.  This routine is useful for users who wish to
             generate RPC style messages without using the RPC package.

     _void_
     **xprt**___**register**(_SVCXPRT_ _*xprt_)

             After RPC service transport handles are created, they should register themselves with
             the RPC service package.  This routine modifies the global variable _svc_fds_.  Service
             implementors usually do not need this routine.

     _void_
     **xprt**___**unregister**(_SVCXPRT_ _*xprt_)

             Before an RPC service transport handle is destroyed, it should unregister itself with
             the RPC service package.  This routine modifies the global variable _svc_fds_.  Service
             implementors usually do not need this routine.

## AVAILABILITY
     These functions are part of libtirpc.

## SEE ALSO
     [rpc_secure(3)](https://www.chedong.com/phpMan.php/man/rpcsecure/3/markdown), [xdr(3)](https://www.chedong.com/phpMan.php/man/xdr/3/markdown)

     _Remote_ _Procedure_ _Calls:_ _Protocol_ _Specification_.

     _Remote_ _Procedure_ _Call_ _Programming_ _Guide_.

     _rpcgen_ _Programming_ _Guide_.

     _RPC:_ _Remote_ _Procedure_ _Call_ _Protocol_ _Specification_, Sun Microsystems, Inc., USC-ISI, RFC1050.

BSD                            February 16, 1988                           BSD
