'\"macro stdmacro
.if n .pH g3n.rpc_clnt_cl @(#)rpc_clnt_cl	40.4 of 10/10/89
.\" Copyright 1989 AT&T
.\" ident	"@(#)svid_rs:rs_lib/rpc_clnt_calls	1.4"
.\ "@(#)rpc_clnt_cal 1.4 89/07/20 SMI;
'\" macro stdmacro
.\" Copyright (c) 1988 Sun Microsystems, Inc. - All Rights Reserved.
.nr X
.if \nX=0 .ds x} rpc_clnt_calls 3N "" "\&"
.if \nX=1 .ds x} rpc_clnt_calls 3N ""
.if \nX=2 .ds x} rpc_clnt_calls 3N "" "\&"
.if \nX=3 .ds x} rpc_clnt_calls "" "" "\&"
.TH \*(x}
.SH NAME
\f4rpc_clnt_calls\fP:  \f4clnt_call\f1, \f4clnt_freeres\f1, \f4clnt_geterr\f1, \f4clnt_perrno\f1, \f4clnt_perror\f1, \f4clnt_sperrno\f1, \f4clnt_sperror\f1, \f4rpc_broadcast\f1, \f4rpc_call\f1 \- library routines for client side calls
.SH 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.
.P
The
\f4clnt_call\f1,
\f4rpc_call\f1
and
\f4rpc_broadcast\f1
routines handle the client side of the
procedure call.
The remaining routines deal with error handling
in the case of errors.
.SS Routines
See \f4rpc\fP(3N) for the definition of the \f4CLIENT\fP data
structure.
.ft 4
.nf
.sp .5
#include <rpc/rpc.h>
.fi
.ft 1
.br
.if t .ne 13
.P
.ft 4
.nf
.sp .5
enum clnt_stat
clnt_call(CLIENT *clnt, const u_long procnum, const xdrproc_t inproc,
	caddr_t in, const xdrproc_t outproc, caddr_t out,
	const struct timeval tout);
.fi
.ft 1
.IP
A function macro that calls the remote procedure
\f2procnum\f1
associated with the client handle,
\f2clnt\f1,
which is obtained with an
RPC
client creation routine such as
\f4clnt_create\f1
[see
rpc_clnt_create(3N)].
The parameter
\f2in\f1
is the address of the procedure's argument(s),
and
\f2out\f1
is the address of where to place the result(s);
\f2inproc\f1
is used to encode the procedure's parameters,
and
\f2outproc\f1
is used to decode the procedure's results;
\f2tout\f1
is the time allowed for results to be returned.
.IP
If the remote call succeeds, the status is returned in
\f4RPC_SUCCESS\f1,
otherwise an appropriate status is returned.
.br
.if t .ne 10
.P
.ft 4
.nf
.sp .5
int clnt_freeres(CLIENT *clnt, const xdrproc_t outproc, caddr_t out);
.fi
.ft 1
.IP
A function macro that frees any data allocated by the RPC/XDR
system when it decoded the results of an RPC call.
The
parameter
\f2out\f1
is the address of the results,
and
\f2outproc\f1
is the XDR routine describing the results.
This routine returns \f41\f1 if the results were successfully
freed,
and \f40\f1 otherwise.
.br
.if t .ne 6
.P
.ft 4
.nf
.sp .5
void
clnt_geterr(const CLIENT *clnt, struct rpc_err *errp);
.fi
.ft 1
.IP
A function macro that copies the error structure out of the client
handle
to the structure at address
\f2errp\f1.
.br
.if t .ne 8
.P
.ft 4
.nf
.sp .5
void
clnt_perrno(const enum clnt_stat stat);
.fi
.ft 1
.IP
Print a message to standard error corresponding
to the condition indicated by
\f2stat\f1.
A
newline
is appended at the end of the message.
Normally used after a procedure call fails,
for instance
\f4rpc_call\f1.
.br
.if t .ne 8
.P
.ft 4
.nf
.sp .5
void
clnt_perror(const CLIENT *clnt, const char *s);
.fi
.ft 1
.IP
Print a message to standard error indicating why an
RPC call failed;
\f2clnt\f1
is the handle used to do the call.
The message is prepended with string
\f2s\f1
and a colon.
A
newline
is appended at the end of the message.
Normally used after a procedure call fails,
for instance
\f4clnt_call\f1.
.br
.if t .ne 9
.P
.ft 4
.nf
.sp .5
char *
clnt_sperrno(const enum clnt_stat stat);
.fi
.ft 1
.IP
Take the same arguments as
\f4clnt_perrno\f1,
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.
.IP
\f4clnt_sperrno\f1
is normally used instead of
\f4clnt_perrno\f1
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 \f4printf\f1
[see \f4printf\fP(3S)],
or if a message format different than that supported by
\f4clnt_perrno\f1
is to be used.
Note:
unlike
\f4clnt_sperror\f1
and
\f4clnt_spcreaterror\f1
[see rpc_clnt_create(3N)],
\f4clnt_sperrno\f1
does not return pointer to static data so the
result will not get overwritten on each call.
.br
.if t .ne 7
.P
.ft 4
.nf
.sp .5
char *
clnt_sperror(const CLIENT *clnt, const char *s);
.fi
.ft 1
.IP
Like
\f4clnt_perror\f1,
except that (like
\f4clnt_sperrno\f1)
it returns a string instead of printing to standard error.
However,
\f4clnt_sperror\f1
does not append a newline at the end of the message.
.IP
Warning:
returns pointer to static data that is overwritten
on each call.
.br
.if t .ne 16
.P
.ft 4
.nf
.sp .5
enum clnt_stat
rpc_broadcast(const u_long prognum, const u_long versnum,
	const u_long procnum, const xdrproc_t inproc, caddr_t in,
	const xdrproc_t outproc, caddr_t out, const resultproc_t eachresult,
	const char *nettype);
.fi
.ft 1
.IP
Like
\f4rpc_call\f1,
except the call message is broadcast to
the connectionless network specified by
\f2nettype\f1.
If
\f2nettype\f1
is \f4NULL\fP,
it defaults to
\f4netpath\f1.
Each time it receives a response,
this routine calls
\f4eachresult\f1,
whose form is:
.RS
.ft 4
.sp .5
.nf
bool_t
eachresult(const caddr_t out, const struct netbuf *addr,
	struct netconfig *netconf);
.ft 1
.fi
.RE
.IP
where
\f2out\f1
is the same as
\f2out\f1
passed to
\f4rpc_broadcast\f1,
except that the remote procedure's output is decoded there;
\f2addr\f1
points to the address of the machine that sent the results,
and
\f2netconf\f1
is the netconfig structure of the transport on which the remote
server responded.
If
\f4eachresult\f1
returns \f40\f1,
\f4rpc_broadcast\f1
waits for more replies;
otherwise it returns with appropriate status.
.IP
Warning:
broadcast file descriptors are limited in size to the
maximum transfer size of that transport.
For Ethernet, this value is 1500 bytes.
.br
.if t .ne 13
.P
.ft 4
.nf
.sp .5
.\" this routine was originally callrpc_cots, then callrpc_nt
enum clnt_stat
rpc_call(const char *host, const u_long prognum,
	const u_long versnum, const u_long procnum,
	const xdrproc_t inproc, const xdrproc_t outproc,
	const char *in, char *out, const char *nettype);
.fi
.ft 1
.IP
Call the remote procedure associated with
\f2prognum\f1,
\f2versnum\f1,
and
\f2procnum\f1
on the machine,
\f2host\f1.
The parameter
\f2in\f1
is the address of the procedure's argument(s),
and
\f2out\f1
is the address of where to place the result(s);
\f2inproc\f1
is used to encode the procedure's parameters,
and
\f2outproc\f1
is used to decode the procedure's results.
.I nettype
can be any of the values listed on \f4rpc\fP(3N).
If
.I nettype
is \f4NULL\fP,
it defaults to
\f4netpath\f1.
This routine returns \f40\f1 if it succeeds,
or the value of
\f4enum clnt_stat\f1
cast to an integer if it fails.
Use the
\f4clnt_perrno\f1
routine to translate failure statuses into messages.
.IP
Warning:
\f4rpc_call\f1
uses the first available transport belonging
to the class
\f2nettype\f1,
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.
.SH SEE ALSO
.na
\f4printf\fP(3S),
\f4rpc\fP(3N),
\f4rpc_clnt_auth\fP(3N),
\f4rpc_clnt_create\fP(3N).
.ad
