rpc_clnt_calls(3N)rpc_clnt_calls(3N)NAME
rpc_clnt_calls: clnt_call, clnt_freeres, clnt_geterr, clnt_perrno,
clnt_perror, clnt_sperrno, clnt_sperror, rpc_broadcast, rpc_call -
library routines for client side calls
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 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.
The clnt_call, rpc_call and rpc_broadcast routines handle the client side
of the procedure call. The remaining routines deal with error handling
in the case of errors.
Routines
See rpc(3N) for the definition of the CLIENT data structure.
#include <rpc/rpc.h>
enum clnt_stat
clnt_call(CLIENT *clnt, rpcproc_t procnum, xdrproc_t inproc,
void *in, xdrproc_t outproc, void *out,
struct timeval tout);
A function 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 [see rpc_clnt_create(3N)]. The
parameter in 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 parameters, and outproc is used to decode the
procedure's results; tout is the time allowed for results to be
returned.
If the remote call succeeds, the status is returned in RPC_SUCCESS,
otherwise an appropriate status is returned.
int clnt_freeres(CLIENT *clnt, xdrproc_t outproc, void *out);
A function macro that frees any data allocated by the RPC/XDR system
when it decoded the results of an RPC call. The parameter out is
the address of the results, and outproc is the XDR routine
describing the results. This routine returns 1 if the results were
successfully freed, and 0 otherwise.
void
clnt_geterr(CLIENT *clnt, struct rpc_err *errp);
A function macro that copies the error structure out of the client
handle to the structure at address errp.
Page 1
rpc_clnt_calls(3N)rpc_clnt_calls(3N)
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.
Normally used after a procedure call fails, for instance rpc_call.
void
clnt_perror(CLIENT *clnt, const 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. Normally used after a procedure call fails, for instance
clnt_call.
char *
clnt_sperrno(enum clnt_stat stat);
Take the same arguments as clnt_perrno, but instead of sending a
message to the standard error indicating why an RPC call failed,
return a pointer to a string which contains the message.
clnt_sperrno 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 output with printf [see printf(3S)], or if a
message format different than that supported by clnt_perrno is to be
used. Note: unlike clnt_sperror and clnt_spcreaterror [see
rpc_clnt_create(3N)], clnt_sperrno does not return pointer to static
data so the result will not get overwritten on each call.
char *
clnt_sperror(CLIENT *clnt, const char *s);
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.
Note: returns pointer to static data that is overwritten on each
call.
enum clnt_stat
rpc_broadcast(rpcprog_t prognum, rpcvers_t versnum,
rpcproc_t procnum, xdrproc_t inproc, void *in,
xdrproc_t outproc, void *out, resultproc_t eachresult,
const char *nettype);
Like rpc_call, except the call message is broadcast to the
connectionless network specified by nettype. If nettype is NULL, it
defaults to netpath. Each time it receives a response, this routine
calls eachresult, whose form is:
Page 2
rpc_clnt_calls(3N)rpc_clnt_calls(3N)
bool_t
eachresult(caddr_t out, struct netbuf *addr,
struct netconfig *netconf);
where out is the same as out passed to rpc_broadcast, except that
the remote procedure'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.
Note: broadcast file descriptors are limited in size to the maximum
transfer size of that transport. For Ethernet, this value is 1500
bytes.
enum clnt_stat
rpc_call(const char *host, rpcprog_t prognum,
rpcvers_t versnum, rpcproc_t procnum,
xdrproc_t inproc, void *in,
xdrproc_t outproc, void *out,
const char *nettype);
Call the remote procedure associated with prognum, versnum, and
procnum on the machine, host. The parameter in 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
parameters, and outproc is used to decode the procedure's results.
nettype can be any of the values listed on rpc(3N). If nettype is
NULL, it defaults to netpath. This routine returns 0 if it
succeeds, or the value of enum clnt_stat cast to an integer if it
fails. Use the clnt_perrno routine to translate failure statuses
into messages.
Note: rpc_call uses the first available transport belonging to the
class nettype, on which it can create a connection. You do not have
control of timeouts or authentication using this routine. There is
also no way to destroy the client handle.
SEE ALSOprintf(3S), rpc(3N), rpc_clnt_auth(3N), rpc_clnt_create(3N)
Page 3