# phpman > man > RPC_CLNT_CALLS(3)

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

## NAME
     **rpc**___**clnt**___**calls**, **clnt**___**call**, **clnt**___**freeres**, **clnt**___**geterr**, **clnt**___**perrno**, **clnt**___**perror**, **clnt**___**sperrno**,
     **clnt**___**sperror**, **rpc**___**broadcast**, **rpc**___**broadcast**___**exp**, **rpc**___**call** — library routines for client side
     calls

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

     _enum_ _clnt_stat_
     **clnt**___**call**(_CLIENT_ _*clnt_, _const_ _rpcproc_t_ _procnum_, _const_ _xdrproc_t_ _inproc_, _const_ _caddr_t_ _in_,
         _const_ _xdrproc_t_ _outproc_, _caddr_t_ _out_, _const_ _struct_ _timeval_ _tout_);

     _bool_t_
     **clnt**___**freeres**(_CLIENT_ _*clnt_, _const_ _xdrproc_t_ _outproc_, _caddr_t_ _out_);

     _void_
     **clnt**___**geterr**(_const_ _CLIENT_ _*_ _clnt_, _struct_ _rpc_err_ _*_ _errp_);

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

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

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

     _char_ _*_
     **clnt**___**sperror**(_CLIENT_ _*clnt_, _const_ _char_ _*_ _s_);

     _enum_ _clnt_stat_
     **rpc**___**broadcast**(_const_ _rpcprog_t_ _prognum_, _const_ _rpcvers_t_ _versnum_, _const_ _rpcproc_t_ _procnum_,
         _const_ _xdrproc_t_ _inproc_, _const_ _caddr_t_ _in_, _const_ _xdrproc_t_ _outproc_, _caddr_t_ _out_,
         _const_ _resultproc_t_ _eachresult_, _const_ _char_ _*nettype_);

     _enum_ _clnt_stat_
     **rpc**___**broadcast**___**exp**(_const_ _rpcprog_t_ _prognum_, _const_ _rpcvers_t_ _versnum_, _const_ _rpcproc_t_ _procnum_,
         _const_ _xdrproc_t_ _xargs_, _caddr_t_ _argsp_, _const_ _xdrproc_t_ _xresults_, _caddr_t_ _resultsp_,
         _const_ _resultproc_t_ _eachresult_, _const_ _int_ _inittime_, _const_ _int_ _waittime_,
         _const_ _char_ _*_ _nettype_);

     _enum_ _clnt_stat_
     **rpc**___**call**(_const_ _char_ _*host_, _const_ _rpcprog_t_ _prognum_, _const_ _rpcvers_t_ _versnum_,
         _const_ _rpcproc_t_ _procnum_, _const_ _xdrproc_t_ _inproc_, _const_ _char_ _*in_, _const_ _xdrproc_t_ _outproc_,
         _char_ _*out_, _const_ _char_ _*nettype_);

## DESCRIPTION
     RPC library routines allow C language programs to make procedure calls on other machines across
     the network.  First, the client calls a procedure to send a request to the server.  Upon re‐
     ceipt of the request, the server calls a dispatch routine to perform the requested service, and
     then sends back a reply.

     The **clnt**___**call**(), **rpc**___**call**(), and **rpc**___**broadcast**() routines handle the client side of the proce‐
     dure call.  The remaining routines deal with error handling in the case of errors.

     Some of the routines take a _CLIENT_ handle as one of the arguments.  A _CLIENT_ handle can be cre‐
     ated by an RPC creation routine such as **clnt**___**create**() (see [rpc_clnt_create(3)](https://www.chedong.com/phpMan.php/man/rpcclntcreate/3/markdown)).

     These routines are safe for use in multithreaded applications.  _CLIENT_ handles can be shared
     between threads, however in this implementation requests by different threads are serialized
     (that is, the first request will receive its results before the second request is sent).

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

     **clnt**___**call**()
            A function macro that calls the remote procedure _procnum_ associated with the client han‐
            dle, _clnt_, which is obtained with an RPC client creation routine such as **clnt**___**create**()
            (see [rpc_clnt_create(3)](https://www.chedong.com/phpMan.php/man/rpcclntcreate/3/markdown)).  The _inproc_ argument is the XDR function used to encode the
            procedure's arguments, and _outproc_ is the XDR function used to decode the procedure's
            results; _in_ is the address of the procedure's argument(s), and _out_ is the address of
            where to place the result(s).  The _tout_ argument is the time allowed for results to be
            returned, which is overridden by a time-out set explicitly through **clnt**___**control**(), see
            [rpc_clnt_create(3)](https://www.chedong.com/phpMan.php/man/rpcclntcreate/3/markdown).  If the remote call succeeds, the status returned is RPC_SUCCESS,
            otherwise an appropriate status is returned.

     **clnt**___**freeres**()
            A function 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 1 if the results were suc‐
            cessfully freed, and 0 otherwise.

     **clnt**___**geterr**()
            A function macro that copies the error structure out of the client handle to the struc‐
            ture at address _errp_.

     **clnt**___**perrno**()
            Print a message to standard error corresponding to the condition indicated by _stat_.  A
            newline is appended.  Normally used after a procedure call fails for a routine for which
            a client handle is not needed, for instance **rpc**___**call**().

     **clnt**___**perror**()
            Print a message to the 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 new‐
            line is appended.  Normally used after a remote procedure call fails for a routine which
            requires a client handle, for instance **clnt**___**call**().

     **clnt**___**sperrno**()
            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 normally used instead of
            **clnt**___**perrno**() when 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 out‐
            put with **printf**() (see [printf(3)](https://www.chedong.com/phpMan.php/man/printf/3/markdown)), or if a message format different than that supported
            by **clnt**___**perrno**() is to be used.  Note: unlike **clnt**___**sperror**() and **clnt**___**spcreateerror**()
            (see [rpc_clnt_create(3)](https://www.chedong.com/phpMan.php/man/rpcclntcreate/3/markdown)), **clnt**___**sperrno**() does not return pointer to static data so the
            result will not get overwritten on each call.

     **clnt**___**sperror**()
            Like **clnt**___**perror**(), except that (like **clnt**___**sperrno**()) it returns a string instead of
            printing to standard error.  However, **clnt**___**sperror**() does not append a newline at the
            end of the message.  Warning: returns pointer to a buffer that is overwritten on each
            call.

     **rpc**___**broadcast**()
            Like **rpc**___**call**(), except the call message is broadcast to all the connectionless trans‐
            ports specified by _nettype_.  If _nettype_ is NULL, it defaults to "netpath".  Each time it
            receives a response, this routine calls **eachresult**(), whose form is: _bool_t_
            **eachresult**(_caddr_t_ _out_, _const_ _struct_ _netbuf_ _*_ _addr_, _const_ _struct_ _netconfig_ _*_ _netconf_)
            where _out_ is the same as _out_ passed to **rpc**___**broadcast**(), except that the remote proce‐
            dure's output is decoded there; _addr_ points to the address of the machine that sent the
            results, and _netconf_ is the netconfig structure of the transport on which the remote
            server responded.  If **eachresult**() returns 0, **rpc**___**broadcast**() waits for more replies;
            otherwise it returns with appropriate status.  Warning: broadcast file descriptors are
            limited in size to the maximum transfer size of that transport.  For Ethernet, this
            value is 1500 bytes.  The **rpc**___**broadcast**() function uses AUTH_SYS credentials by default
            (see [rpc_clnt_auth(3)](https://www.chedong.com/phpMan.php/man/rpcclntauth/3/markdown)).

     **rpc**___**broadcast**___**exp**()
            Like **rpc**___**broadcast**(), except that the initial timeout, _inittime_ and the maximum timeout,
            _waittime_ are specified in milliseconds.  The _inittime_ argument is the initial time that
            **rpc**___**broadcast**___**exp**() waits before resending the request.  After the first resend, the re-
            transmission interval increases exponentially until it exceeds _waittime_.

     **rpc**___**call**()
            Call the remote procedure associated with _prognum_, _versnum_, and _procnum_ on the machine,
            _host_.  The _inproc_ argument is used to encode the procedure's arguments, and _outproc_ is
            used to decode the procedure's results; _in_ is the address of the procedure's argu‐
            ment(s), and _out_ is the address of where to place the result(s).  The _nettype_ argument
            can be any of the values listed on [rpc(3)](https://www.chedong.com/phpMan.php/man/rpc/3/markdown).  This routine returns RPC_SUCCESS if it suc‐
            ceeds, or an appropriate status is returned.  Use the **clnt**___**perrno**() routine to translate
            failure status into error messages.  Warning: **rpc**___**call**() uses the first available trans‐
            port belonging to the class _nettype_, on which it can create a connection.  You do not
            have control of timeouts or authentication using this routine.

## AVAILABILITY
     These functions are part of libtirpc.

## SEE ALSO
     [printf(3)](https://www.chedong.com/phpMan.php/man/printf/3/markdown), [rpc(3)](https://www.chedong.com/phpMan.php/man/rpc/3/markdown), [rpc_clnt_auth(3)](https://www.chedong.com/phpMan.php/man/rpcclntauth/3/markdown), [rpc_clnt_create(3)](https://www.chedong.com/phpMan.php/man/rpcclntcreate/3/markdown)

BSD                               May 7, 1993                              BSD
