[BACK]Return to rpc_clnt_calls.3 CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / lib / libc / rpc

File: [cvs.NetBSD.org] / src / lib / libc / rpc / rpc_clnt_calls.3 (download)

Revision 1.7, Sat Dec 3 15:16:19 2005 UTC (18 years, 3 months ago) by yamt
Branch: MAIN
CVS Tags: yamt-pf42-baseX, yamt-pf42-base4, yamt-pf42-base3, yamt-pf42-base2, yamt-pf42-base, yamt-pf42, yamt-pagecache-tag8, yamt-pagecache-base9, yamt-pagecache-base8, yamt-pagecache-base7, yamt-pagecache-base6, yamt-pagecache-base5, yamt-pagecache-base4, yamt-pagecache-base3, yamt-pagecache-base2, yamt-pagecache-base, yamt-pagecache, wrstuden-revivesa-base-3, wrstuden-revivesa-base-2, wrstuden-revivesa-base-1, wrstuden-revivesa-base, wrstuden-revivesa, wrstuden-fixsa-newbase, wrstuden-fixsa-base-1, wrstuden-fixsa-base, wrstuden-fixsa, tls-maxphys-base, tls-maxphys, tls-earlyentropy-base, tls-earlyentropy, riastradh-xf86-video-intel-2-7-1-pre-2-21-15, riastradh-drm2-base3, riastradh-drm2-base2, riastradh-drm2-base1, riastradh-drm2-base, riastradh-drm2, prg-localcount2-base3, prg-localcount2-base2, prg-localcount2-base1, prg-localcount2-base, prg-localcount2, phil-wifi-base, phil-wifi-20200421, phil-wifi-20200411, phil-wifi-20200406, phil-wifi-20191119, phil-wifi-20190609, phil-wifi, pgoyette-localcount-base, pgoyette-localcount-20170426, pgoyette-localcount-20170320, pgoyette-localcount-20170107, pgoyette-localcount-20161104, pgoyette-localcount-20160806, pgoyette-localcount-20160726, pgoyette-localcount, pgoyette-compat-merge-20190127, pgoyette-compat-base, pgoyette-compat-20190127, pgoyette-compat-20190118, pgoyette-compat-1226, pgoyette-compat-1126, pgoyette-compat-1020, pgoyette-compat-0930, pgoyette-compat-0906, pgoyette-compat-0728, pgoyette-compat-0625, pgoyette-compat-0521, pgoyette-compat-0502, pgoyette-compat-0422, pgoyette-compat-0415, pgoyette-compat-0407, pgoyette-compat-0330, pgoyette-compat-0322, pgoyette-compat-0315, pgoyette-compat, perseant-stdc-iso10646-base, perseant-stdc-iso10646, netbsd-9-base, netbsd-9-3-RELEASE, netbsd-9-2-RELEASE, netbsd-9-1-RELEASE, netbsd-9-0-RELEASE, netbsd-9-0-RC2, netbsd-9-0-RC1, netbsd-9, netbsd-8-base, netbsd-8-2-RELEASE, netbsd-8-1-RELEASE, netbsd-8-1-RC1, netbsd-8-0-RELEASE, netbsd-8-0-RC2, netbsd-8-0-RC1, netbsd-8, netbsd-7-nhusb-base-20170116, netbsd-7-nhusb-base, netbsd-7-nhusb, netbsd-7-base, netbsd-7-2-RELEASE, netbsd-7-1-RELEASE, netbsd-7-1-RC2, netbsd-7-1-RC1, netbsd-7-1-2-RELEASE, netbsd-7-1-1-RELEASE, netbsd-7-1, netbsd-7-0-RELEASE, netbsd-7-0-RC3, netbsd-7-0-RC2, netbsd-7-0-RC1, netbsd-7-0-2-RELEASE, netbsd-7-0-1-RELEASE, netbsd-7-0, netbsd-7, netbsd-6-base, netbsd-6-1-RELEASE, netbsd-6-1-RC4, netbsd-6-1-RC3, netbsd-6-1-RC2, netbsd-6-1-RC1, netbsd-6-1-5-RELEASE, netbsd-6-1-4-RELEASE, netbsd-6-1-3-RELEASE, netbsd-6-1-2-RELEASE, netbsd-6-1-1-RELEASE, netbsd-6-1, netbsd-6-0-RELEASE, netbsd-6-0-RC2, netbsd-6-0-RC1, netbsd-6-0-6-RELEASE, netbsd-6-0-5-RELEASE, netbsd-6-0-4-RELEASE, netbsd-6-0-3-RELEASE, netbsd-6-0-2-RELEASE, netbsd-6-0-1-RELEASE, netbsd-6-0, netbsd-6, netbsd-5-base, netbsd-5-2-RELEASE, netbsd-5-2-RC1, netbsd-5-2-3-RELEASE, netbsd-5-2-2-RELEASE, netbsd-5-2-1-RELEASE, netbsd-5-2, netbsd-5-1-RELEASE, netbsd-5-1-RC4, netbsd-5-1-RC3, netbsd-5-1-RC2, netbsd-5-1-RC1, netbsd-5-1-5-RELEASE, netbsd-5-1-4-RELEASE, netbsd-5-1-3-RELEASE, netbsd-5-1-2-RELEASE, netbsd-5-1-1-RELEASE, netbsd-5-1, netbsd-5-0-RELEASE, netbsd-5-0-RC4, netbsd-5-0-RC3, netbsd-5-0-RC2, netbsd-5-0-RC1, netbsd-5-0-2-RELEASE, netbsd-5-0-1-RELEASE, netbsd-5-0, netbsd-5, netbsd-4-base, netbsd-4-0-RELEASE, netbsd-4-0-RC5, netbsd-4-0-RC4, netbsd-4-0-RC3, netbsd-4-0-RC2, netbsd-4-0-RC1, netbsd-4-0-1-RELEASE, netbsd-4-0, netbsd-4, netbsd-10-base, netbsd-10-0-RELEASE, netbsd-10-0-RC6, netbsd-10-0-RC5, netbsd-10-0-RC4, netbsd-10-0-RC3, netbsd-10-0-RC2, netbsd-10-0-RC1, netbsd-10, mjf-devfs2-base, mjf-devfs2, matt-premerge-20091211, matt-nb8-mediatek-base, matt-nb8-mediatek, matt-nb6-plus-nbase, matt-nb6-plus-base, matt-nb6-plus, matt-nb5-pq3-base, matt-nb5-pq3, matt-nb5-mips64-u2-k2-k4-k7-k8-k9, matt-nb5-mips64-u1-k1-k5, matt-nb5-mips64-premerge-20101231, matt-nb5-mips64-premerge-20091211, matt-nb5-mips64-k15, matt-nb5-mips64, matt-nb4-mips64-k7-u2a-k9b, matt-mips64-premerge-20101231, matt-mips64-base2, matt-mips64-base, matt-mips64, matt-armv6-prevmlocking, matt-armv6-nbase, matt-armv6-base, matt-armv6, localcount-20160914, keiichi-mipv6-base, keiichi-mipv6, jym-xensuspend-nbase, jym-xensuspend-base, jym-xensuspend, is-mlppp-base, is-mlppp, hpcarm-cleanup-nbase, hpcarm-cleanup-base, hpcarm-cleanup, cube-autoconf-base, cube-autoconf, cjep_sun2x-base1, cjep_sun2x-base, cjep_sun2x, cjep_staticlib_x-base1, cjep_staticlib_x-base, cjep_staticlib_x, christos-time_t-nbase, christos-time_t-base, christos-time_t, cherry-xenmp-base, cherry-xenmp, bouyer-socketcan-base1, bouyer-socketcan-base, bouyer-socketcan, bouyer-quota2-nbase, bouyer-quota2-base, bouyer-quota2, agc-symver-base, agc-symver, abandoned-netbsd-4-base, abandoned-netbsd-4, HEAD
Changes since 1.6: +4 -4 lines

- constify and remove __UNCONST from caller of clnt_call().
- use __UNCONST where approproate.

.\" @(#)rpc_clnt_calls.3n 1.30 93/08/31 SMI; from SVr4
.\" Copyright 1989 AT&T
.\" @(#)rpc_clnt_calls 1.4 89/07/20 SMI;
.\" Copyright (c) 1988 Sun Microsystems, Inc. - All Rights Reserved.
.\"	$NetBSD: rpc_clnt_calls.3,v 1.7 2005/12/03 15:16:19 yamt Exp $
.Dd December 4, 2005
.Dt RPC_CLNT_CALLS 3
.Os
.Sh NAME
.Nm rpc_clnt_calls ,
.Nm clnt_call ,
.Nm clnt_freeres ,
.Nm clnt_geterr ,
.Nm clnt_perrno ,
.Nm clnt_perror ,
.Nm clnt_sperrno ,
.Nm clnt_sperror ,
.Nm rpc_broadcast ,
.Nm rpc_broadcast_exp ,
.Nm rpc_call
.Nd library routines for client side calls
.Sh LIBRARY
.Lb libc
.Sh SYNOPSIS
.In rpc/rpc.h
.Ft "enum clnt_stat"
.Fn clnt_call "CLIENT *clnt" "const rpcproc_t procnum" "const xdrproc_t inproc" "const char *in" "const xdrproc_t outproc" "caddr_t out" "const struct timeval tout"
.Ft bool_t
.Fn clnt_freeres "CLIENT *clnt" "const xdrproc_t outproc" "caddr_t out"
.Ft void
.Fn clnt_geterr "const CLIENT * clnt" "struct rpc_err * errp"
.Ft void
.Fn clnt_perrno "const enum clnt_stat stat"
.Ft void
.Fn clnt_perror "const CLIENT * clnt" "const char *s"
.Ft "char *"
.Fn clnt_sperrno "const enum clnt_stat stat"
.Ft "char *"
.Fn clnt_sperror "const CLIENT *clnt" "const char * s"
.\" Note the clustered Fn arguments. It can't take more than 9. XXX
.Ft "enum clnt_stat"
.Fn rpc_broadcast "const rpcprog_t prognum, const rpcvers_t versnum" "const rpcproc_t procnum" "const xdrproc_t inproc" "const char *in" "const xdrproc_t outproc" "caddr_t out" "const resultproc_t eachresult" "const char *nettype"
.Ft "enum clnt_stat"
.Fn rpc_broadcast_exp "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 int inittime" "const int waittime" "const resultproc_t eachresult" "const char * nettype"
.Ft "enum clnt_stat"
.Fn 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"
.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 request to the server.
Upon receipt of the request, the server calls a dispatch routine
to perform the requested service, and then sends back a reply.
.Pp
The
.Fn clnt_call ,
.Fn rpc_call ,
and
.Fn rpc_broadcast
routines handle the client side of the procedure call.
The remaining routines deal with error handling in the case of errors.
.Pp
Some of the routines take a
.Dv CLIENT
handle as one of the parameters.
A
.Dv CLIENT
handle can be created by an RPC creation routine such as
.Fn clnt_create
(see
.Xr rpc_clnt_create 3 ) .
.Pp
These routines are safe for use in multithreaded applications.
.Dv 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).
.Sh ROUTINES
See
.Xr rpc 3
for the definition of the
.Dv CLIENT
data structure.
.Pp
.Bl -tag -width XXXXX
.It Fn clnt_call
A function macro that calls the remote procedure
.Fa procnum
associated with the client handle,
.Fa clnt ,
which is obtained with an RPC
client creation routine such as
.Fn clnt_create
(see
.Xr rpc_clnt_create 3 ) .
The parameter
.Fn inproc
is the XDR function used to encode the procedure's parameters, and
.Fn outproc
is the XDR function used to decode the procedure's results;
.Fn in
is the address of the procedure's argument(s), and
.Fn out
is the address of where to place the result(s).
.Fn tout
is the time allowed for results to be returned, which is overridden by
a time-out set explicitly through
.Fn clnt_control ,
see
.Xr rpc_clnt_create 3 .
If the remote call succeeds, the status returned is
.Dv RPC_SUCCESS ,
otherwise an appropriate status is returned.
.Pp
.It Fn 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
.Fa out
is the address of the results, and
.Fa outproc
is the XDR routine describing the results.
This routine returns 1 if the results were successfully freed,
and 0 otherwise.
.Pp
.It Fn clnt_geterr
A function macro that copies the error structure out of the client
handle to the structure at address
.Fa errp .
.Pp
.It Fn clnt_perrno
Print a message to standard error corresponding
to the condition indicated by
.Fa 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
.Fn rpc_call .
.Pp
.It Fn clnt_perror
Print a message to the standard error indicating why an
RPC call failed;
.Fa clnt
is the handle used to do the call.
The message is prepended with string
.Fa 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
.Fn clnt_call .
.Pp
.It Fn clnt_sperrno
Take the same arguments as
.Fn 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.
.Fn clnt_sperrno
is normally used instead of
.Fn 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
.Fn printf
(see
.Xr printf 3 ) ,
or if a message format different than that supported by
.Fn clnt_perrno
is to be used.
Note:
unlike
.Fn clnt_sperror
and
.Fn clnt_spcreaterror
(see
.Xr rpc_clnt_create 3 ) ,
.Fn clnt_sperrno
does not return pointer to static data so the
result will not get overwritten on each call.
.Pp
.It Fn clnt_sperror
Like
.Fn clnt_perror ,
except that (like
.Fn clnt_sperrno )
it returns a string instead of printing to standard error.
However,
.Fn 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.
.Pp
.It Fn rpc_broadcast
Like
.Fn rpc_call ,
except the call message is broadcast to
all the connectionless transports specified by
.Fa nettype .
If
.Fa nettype
is
.Dv NULL ,
it defaults to
.Dq netpath .
Each time it receives a response,
this routine calls
.Fn eachresult ,
whose form is:
.Ft bool_t
.Fn eachresult "caddr_t out" "const struct netbuf * addr" "const struct netconfig * netconf"
where
.Fa out
is the same as
.Fa out
passed to
.Fn rpc_broadcast ,
except that the remote procedure's output is decoded there;
.Fa addr
points to the address of the machine that sent the results, and
.Fa netconf
is the netconfig structure of the transport on which the remote
server responded.
If
.Fn eachresult
returns 0,
.Fn 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.
.Fn rpc_broadcast
uses
.Dv AUTH_SYS
credentials by default (see
.Xr rpc_clnt_auth 3 ) .
.Pp
.It Fn rpc_broadcast_exp
Like
.Fn rpc_broadcast ,
except that the initial timeout,
.Fa inittime
and the maximum timeout,
.Fa waittime
are specified in milliseconds.
.Fa inittime
is the initial time that
.Fn rpc_broadcast_exp
waits before resending the request.
After the first resend, the re-transmission interval
increases exponentially until it exceeds
.Fa waittime .
.Pp
.It Fn rpc_call
Call the remote procedure associated with
.Fa prognum ,
.Fa versnum ,
and
.Fa procnum
on the machine,
.Fa host .
The parameter
.Fa inproc
is used to encode the procedure's parameters, and
.Fa outproc
is used to decode the procedure's results;
.Fa in
is the address of the procedure's argument(s), and
.Fa out
is the address of where to place the result(s).
.Fa nettype
can be any of the values listed on
.Xr rpc 3 .
This routine returns
.Dv RPC_SUCCESS
if it succeeds, or an appropriate status is returned.
Use the
.Fn clnt_perrno
routine to translate failure status into error messages.
Warning:
.Fn rpc_call
uses the first available transport belonging
to the class
.Fa nettype ,
on which it can create a connection.
You do not have control of timeouts or authentication
using this routine.
.El
.Sh SEE ALSO
.Xr printf 3 ,
.Xr rpc 3 ,
.Xr rpc_clnt_auth 3 ,
.Xr rpc_clnt_create 3