1RPC_CLNT_CALLS(3) BSD Library Functions Manual RPC_CLNT_CALLS(3)
2
4 rpc_clnt_calls, clnt_call, clnt_freeres, clnt_geterr, clnt_perrno,
5 clnt_perror, clnt_sperrno, clnt_sperror, rpc_broadcast,
6 rpc_broadcast_exp, rpc_call — library routines for client side calls
7
9 Standard C Library (libc, -lc)
10
12 #include <rpc/rpc.h>
13
14 enum clnt_stat
15 clnt_call(CLIENT *clnt, const rpcproc_t procnum, const xdrproc_t inproc,
16 const caddr_t in, const xdrproc_t outproc, caddr_t out,
17 const struct timeval tout);
18
19 bool_t
20 clnt_freeres(CLIENT *clnt, const xdrproc_t outproc, caddr_t out);
21
22 void
23 clnt_geterr(const CLIENT * clnt, struct rpc_err * errp);
24
25 void
26 clnt_perrno(const enum clnt_stat stat);
27
28 void
29 clnt_perror(CLIENT *clnt, const char *s);
30
31 char *
32 clnt_sperrno(const enum clnt_stat stat);
33
34 char *
35 clnt_sperror(CLIENT *clnt, const char * s);
36
37 enum clnt_stat
38 rpc_broadcast(const rpcprog_t prognum, const rpcvers_t versnum,
39 const rpcproc_t procnum, const xdrproc_t inproc, const caddr_t in,
40 const xdrproc_t outproc, caddr_t out, const resultproc_t eachresult,
41 const char *nettype);
42
43 enum clnt_stat
44 rpc_broadcast_exp(const rpcprog_t prognum, const rpcvers_t versnum,
45 const rpcproc_t procnum, const xdrproc_t xargs, caddr_t argsp,
46 const xdrproc_t xresults, caddr_t resultsp,
47 const resultproc_t eachresult, const int inittime,
48 const int waittime, const char * nettype);
49
50 enum clnt_stat
51 rpc_call(const char *host, const rpcprog_t prognum,
52 const rpcvers_t versnum, const rpcproc_t procnum,
53 const xdrproc_t inproc, const char *in, const xdrproc_t outproc,
54 char *out, const char *nettype);
55
57 RPC library routines allow C language programs to make procedure calls on
58 other machines across the network. First, the client calls a procedure
59 to send a request to the server. Upon receipt of the request, the server
60 calls a dispatch routine to perform the requested service, and then sends
61 back a reply.
62
63 The clnt_call(), rpc_call(), and rpc_broadcast() routines handle the
64 client side of the procedure call. The remaining routines deal with
65 error handling in the case of errors.
66
67 Some of the routines take a CLIENT handle as one of the arguments. A
68 CLIENT handle can be created by an RPC creation routine such as
69 clnt_create() (see rpc_clnt_create(3)).
70
71 These routines are safe for use in multithreaded applications. CLIENT
72 handles can be shared between threads, however in this implementation
73 requests by different threads are serialized (that is, the first request
74 will receive its results before the second request is sent).
75
77 See rpc(3) for the definition of the CLIENT data structure.
78
79 clnt_call()
80 A function macro that calls the remote procedure procnum associ‐
81 ated with the client handle, clnt, which is obtained with an RPC
82 client creation routine such as clnt_create() (see
83 rpc_clnt_create(3)). The inproc argument is the XDR function used
84 to encode the procedure's arguments, and outproc is the XDR func‐
85 tion used to decode the procedure's results; in is the address of
86 the procedure's argument(s), and out is the address of where to
87 place the result(s). The tout argument is the time allowed for
88 results to be returned, which is overridden by a time-out set
89 explicitly through clnt_control(), see rpc_clnt_create(3). If the
90 remote call succeeds, the status returned is RPC_SUCCESS, other‐
91 wise an appropriate status is returned.
92
93 clnt_freeres()
94 A function macro that frees any data allocated by the RPC/XDR sys‐
95 tem when it decoded the results of an RPC call. The out argument
96 is the address of the results, and outproc is the XDR routine
97 describing the results. This routine returns 1 if the results
98 were successfully freed, and 0 otherwise.
99
100 clnt_geterr()
101 A function macro that copies the error structure out of the client
102 handle to the structure at address errp.
103
104 clnt_perrno()
105 Print a message to standard error corresponding to the condition
106 indicated by stat. A newline is appended. Normally used after a
107 procedure call fails for a routine for which a client handle is
108 not needed, for instance rpc_call().
109
110 clnt_perror()
111 Print a message to the standard error indicating why an RPC call
112 failed; clnt is the handle used to do the call. The message is
113 prepended with string s and a colon. A newline is appended. Nor‐
114 mally used after a remote procedure call fails for a routine which
115 requires a client handle, for instance clnt_call().
116
117 clnt_sperrno()
118 Take the same arguments as clnt_perrno(), but instead of sending a
119 message to the standard error indicating why an RPC call failed,
120 return a pointer to a string which contains the message. The
121 clnt_sperrno() function is normally used instead of clnt_perrno()
122 when the program does not have a standard error (as a program run‐
123 ning as a server quite likely does not), or if the programmer does
124 not want the message to be output with printf() (see printf(3)),
125 or if a message format different than that supported by
126 clnt_perrno() is to be used. Note: unlike clnt_sperror() and
127 clnt_spcreateerror() (see rpc_clnt_create(3)), clnt_sperrno() does
128 not return pointer to static data so the result will not get over‐
129 written on each call.
130
131 clnt_sperror()
132 Like clnt_perror(), except that (like clnt_sperrno()) it returns a
133 string instead of printing to standard error. However,
134 clnt_sperror() does not append a newline at the end of the mes‐
135 sage. Warning: returns pointer to a buffer that is overwritten on
136 each call.
137
138 rpc_broadcast()
139 Like rpc_call(), except the call message is broadcast to all the
140 connectionless transports specified by nettype. If nettype is
141 NULL, it defaults to "netpath". Each time it receives a response,
142 this routine calls eachresult(), whose form is: bool_t
143 eachresult(caddr_t out, const struct netbuf * addr, const struct
144 netconfig * netconf) where out is the same as out passed to
145 rpc_broadcast(), except that the remote procedure's output is
146 decoded there; addr points to the address of the machine that sent
147 the results, and netconf is the netconfig structure of the trans‐
148 port on which the remote server responded. If eachresult()
149 returns 0, rpc_broadcast() waits for more replies; otherwise it
150 returns with appropriate status. Warning: broadcast file descrip‐
151 tors are limited in size to the maximum transfer size of that
152 transport. For Ethernet, this value is 1500 bytes. The
153 rpc_broadcast() function uses AUTH_SYS credentials by default (see
154 rpc_clnt_auth(3)).
155
156 rpc_broadcast_exp()
157 Like rpc_broadcast(), except that the initial timeout, inittime
158 and the maximum timeout, waittime are specified in milliseconds.
159 The inittime argument is the initial time that rpc_broadcast_exp()
160 waits before resending the request. After the first resend, the
161 re-transmission interval increases exponentially until it exceeds
162 waittime.
163
164 rpc_call()
165 Call the remote procedure associated with prognum, versnum, and
166 procnum on the machine, host. The inproc argument is used to
167 encode the procedure's arguments, and outproc is used to decode
168 the procedure's results; in is the address of the procedure's
169 argument(s), and out is the address of where to place the
170 result(s). The nettype argument can be any of the values listed
171 on rpc(3). This routine returns RPC_SUCCESS if it succeeds, or an
172 appropriate status is returned. Use the clnt_perrno() routine to
173 translate failure status into error messages. Warning: rpc_call()
174 uses the first available transport belonging to the class nettype,
175 on which it can create a connection. You do not have control of
176 timeouts or authentication using this routine.
177
179 printf(3), rpc(3), rpc_clnt_auth(3), rpc_clnt_create(3)
180
181BSD May 7, 1993 BSD