HP-UX Reference (11i v2 07/12) - 3 Library Functions N-Z (vol 7)

r
rpc_clnt_calls(3N) rpc_clnt_calls(3N)
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 pro-
cedure 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 parameters. A
CLIENT handle can be created
by an RPC creation routine such as
clnt_create() (see rpc_clnt_create(3N)).
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).
The HP-UX implementation of RPC only supports the X/Open Transport Interface (XTI). Applications that
are written using the Transport Layer Interface (TLI) and wish to use RPC, must convert their application
to XTI.
Routines
See rpc(3N) for the definition of the
CLIENT data structure.
enum clnt_stat clnt_call()
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 inproc is the XDR function used to encode the procedures
parameters, 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). tout 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(3N).
If the remote call succeeds, the status returned is
RPC_SUCCESS , otherwise an appropriate status is
returned.
bool_t 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 parameter out is the address of the results, and outproc is the XDR routine describ-
ing the results. This routine returns
1 if the results were successfully freed, and 0 otherwise.
void clnt_geterr()
A function macro that copies the error structure out of the client handle to the structure at address
errp.
void 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() .
void 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 newline is appended. Normally used
after a remote procedure call fails for a routine which requires a client handle, for instance
clnt_call() .
char *clnt_sperrno()
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()
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 mes-
sage.
336 Hewlett-Packard Company 2 HP-UX 11i Version 2: December 2007 Update