1RPC_CLNT_CREATE(3)       BSD Library Functions Manual       RPC_CLNT_CREATE(3)
2

NAME

4     rpc_clnt_create, clnt_control, clnt_create, clnt_create_timed,
5     clnt_create_vers, clnt_create_vers_timed, clnt_destroy, clnt_dg_create,
6     clnt_pcreateerror, clnt_raw_create, clnt_spcreateerror, clnt_tli_create,
7     clnt_tp_create, clnt_tp_create_timed, clnt_vc_create, rpc_createerr 
8     library routines for dealing with creation and manipulation of CLIENT
9     handles
10

LIBRARY

12     Standard C Library (libc, -lc)
13

SYNOPSIS

15     #include <rpc/rpc.h>
16
17     bool_t
18     clnt_control(CLIENT *clnt, const u_int req, char *info);
19
20     CLIENT *
21     clnt_create(const char * host, const rpcprog_t prognum,
22         const rpcvers_t versnum, const char *nettype);
23
24     CLIENT *
25     clnt_create_timed(const char * host, const rpcprog_t prognum,
26         const rpcvers_t versnum, const char *nettype,
27         const struct timeval *timeout);
28
29     CLIENT *
30     clnt_create_vers(const char * host, const rpcprog_t prognum,
31         rpcvers_t *vers_outp, const rpcvers_t vers_low,
32         const rpcvers_t vers_high, const char *nettype);
33
34     CLIENT *
35     clnt_create_vers_timed(const char * host, const rpcprog_t prognum,
36         rpcvers_t *vers_outp, const rpcvers_t vers_low,
37         const rpcvers_t vers_high, char *nettype,
38         const struct timeval *timeout);
39
40     void
41     clnt_destroy(CLIENT *clnt);
42
43     CLIENT *
44     clnt_dg_create(const int fildes, const struct netbuf *svcaddr,
45         const rpcprog_t prognum, const rpcvers_t versnum, const u_int sendsz,
46         const u_int recvsz);
47
48     void
49     clnt_pcreateerror(const char *s);
50
51     char *
52     clnt_spcreateerror(const char *s);
53
54     CLIENT *
55     clnt_raw_create(const rpcprog_t prognum, const rpcvers_t versnum);
56
57     CLIENT *
58     clnt_tli_create(const int fildes, const struct netconfig *netconf,
59         const struct netbuf *svcaddr, const rpcprog_t prognum,
60         const rpcvers_t versnum, const u_int sendsz, const u_int recvsz);
61
62     CLIENT *
63     clnt_tp_create(const char * host, const rpcprog_t prognum,
64         const rpcvers_t versnum, const struct netconfig *netconf);
65
66     CLIENT *
67     clnt_tp_create_timed(const char * host, const rpcprog_t prognum,
68         const rpcvers_t versnum, const struct netconfig *netconf,
69         const struct timeval *timeout);
70
71     CLIENT *
72     clnt_vc_create(const int fildes, const struct netbuf *svcaddr,
73         const rpcprog_t prognum, const rpcvers_t versnum, u_int sendsz,
74         u_int recvsz);
75

DESCRIPTION

77     RPC library routines allow C language programs to make procedure calls on
78     other machines across the network.  First a CLIENT handle is created and
79     then the client calls a procedure to send a request to the server.  On
80     receipt of the request, the server calls a dispatch routine to perform
81     the requested service, and then sends a reply.
82

Routines

84     clnt_control()
85              A function macro to change or retrieve various information about
86              a client object.  The req argument indicates the type of opera‐
87              tion, and info is a pointer to the information.  For both con‐
88              nectionless and connection-oriented transports, the supported
89              values of req and their argument types and what they do are:
90
91              CLSET_TIMEOUT      struct timeval *    set total timeout
92              CLGET_TIMEOUT      struct timeval *    get total timeout
93
94              Note: if you set the timeout using clnt_control(), the timeout
95              argument passed by clnt_call() is ignored in all subsequent
96              calls.
97
98              Note: If you set the timeout value to 0, clnt_control() immedi‐
99              ately returns an error (RPC_TIMEDOUT).  Set the timeout argument
100              to 0 for batching calls.
101
102              CLGET_SVC_ADDR     struct netbuf *     get servers address
103              CLGET_FD           int *               get fd from handle
104              CLSET_FD_CLOSE     void                close fd on destroy
105              CLSET_FD_NCLOSE    void                don't close fd on destroy
106              CLGET_VERS         u_int32_t *         get RPC program version
107              CLSET_VERS         u_int32_t *         set RPC program version
108              CLGET_XID          u_int32_t *         get XID of previous call
109              CLSET_XID          u_int32_t *         set XID of next call
110
111              The following operations are valid for connectionless transports
112              only:
113
114              CLSET_RETRY_TIMEOUT    struct timeval *    set the retry timeout
115              CLGET_RETRY_TIMEOUT    struct timeval *    get the retry timeout
116              CLSET_CONNECT          int *               use connect(2)
117
118              The retry timeout is the time that RPC waits for the server to
119              reply before retransmitting the request.  The clnt_control()
120              function returns TRUE on success and FALSE on failure.
121
122     clnt_create()
123              Generic client creation routine for program prognum and version
124              versnum.  The host argument identifies the name of the remote
125              host where the server is located.  The nettype argument indi‐
126              cates the class of transport protocol to use.  The transports
127              are tried in left to right order in NETPATH environment variable
128              or in top to bottom order in the netconfig database.  The
129              clnt_create() function tries all the transports of the nettype
130              class available from the NETPATH environment variable and the
131              netconfig database, and chooses the first successful one.  A
132              default timeout is set and can be modified using clnt_control().
133              This routine returns NULL if it fails.  The clnt_pcreateerror()
134              routine can be used to print the reason for failure.
135
136              Note: clnt_create() returns a valid client handle even if the
137              particular version number supplied to clnt_create() is not reg‐
138              istered with the rpcbind(8) service.  This mismatch will be dis‐
139              covered by a clnt_call() later (see rpc_clnt_calls(3)).
140
141     clnt_create_timed()
142              Generic client creation routine which is similar to
143              clnt_create() but which also has the additional argument timeout
144              that specifies the maximum amount of time allowed for each
145              transport class tried.  In all other respects, the
146              clnt_create_timed() call behaves exactly like the clnt_create()
147              call.
148
149     clnt_create_vers()
150              Generic client creation routine which is similar to
151              clnt_create() but which also checks for the version availabil‐
152              ity.  The host argument identifies the name of the remote host
153              where the server is located.  The nettype argument indicates the
154              class transport protocols to be used.  If the routine is suc‐
155              cessful it returns a client handle created for the highest ver‐
156              sion between vers_low and vers_high that is supported by the
157              server.  The vers_outp argument is set to this value.  That is,
158              after a successful return vers_low <= *vers_outp <= vers_high.
159              If no version between vers_low and vers_high is supported by the
160              server then the routine fails and returns NULL.  A default time‐
161              out is set and can be modified using clnt_control().  This rou‐
162              tine returns NULL if it fails.  The clnt_pcreateerror() routine
163              can be used to print the reason for failure.  Note:
164              clnt_create() returns a valid client handle even if the particu‐
165              lar version number supplied to clnt_create() is not registered
166              with the rpcbind(8) service.  This mismatch will be discovered
167              by a clnt_call() later (see rpc_clnt_calls(3)).  However,
168              clnt_create_vers() does this for you and returns a valid handle
169              only if a version within the range supplied is supported by the
170              server.
171
172     clnt_create_vers_timed()
173              Generic client creation routine which is similar to
174              clnt_create_vers() but which also has the additional argument
175              timeout that specifies the maximum amount of time allowed for
176              each transport class tried.  In all other respects, the
177              clnt_create_vers_timed() call behaves exactly like the
178              clnt_create_vers() call.
179
180     clnt_destroy()
181              A function macro that destroys the client's RPC handle.
182              Destruction usually involves deallocation of private data struc‐
183              tures, including clnt itself.  Use of clnt is undefined after
184              calling clnt_destroy().  If the RPC library opened the associ‐
185              ated file descriptor, or CLSET_FD_CLOSE was set using
186              clnt_control(), the file descriptor will be closed.  The caller
187              should call auth_destroy(clnt->cl_auth) (before calling
188              clnt_destroy()) to destroy the associated AUTH structure (see
189              rpc_clnt_auth(3)).
190
191     clnt_dg_create()
192              This routine creates an RPC client for the remote program
193              prognum and version versnum; the client uses a connectionless
194              transport.  The remote program is located at address svcaddr.
195              The fildes argument is an open and bound file descriptor.  This
196              routine will resend the call message in intervals of 15 seconds
197              until a response is received or until the call times out.  The
198              total time for the call to time out is specified by clnt_call()
199              (see clnt_call() in rpc_clnt_calls(3)).  The retry time out and
200              the total time out periods can be changed using clnt_control().
201              The user may set the size of the send and receive buffers with
202              the sendsz and recvsz arguments; values of 0 choose suitable
203              defaults.  This routine returns NULL if it fails.
204
205     clnt_pcreateerror()
206              Print a message to standard error indicating why a client RPC
207              handle could not be created.  The message is prepended with the
208              string s and a colon, and appended with a newline.
209
210     clnt_spcreateerror()
211              Like clnt_pcreateerror(), except that it returns a string
212              instead of printing to the standard error.  A newline is not
213              appended to the message in this case.  Warning: returns a
214              pointer to a buffer that is overwritten on each call.
215
216     clnt_raw_create()
217              This routine creates an RPC client handle for the remote program
218              prognum and version versnum.  The transport used to pass mes‐
219              sages to the service is a buffer within the process's address
220              space, so the corresponding RPC server should live in the same
221              address space; (see svc_raw_create() in rpc_svc_create(3)).
222              This allows simulation of RPC and measurement of RPC overheads,
223              such as round trip times, without any kernel or networking
224              interference.  This routine returns NULL if it fails.  The
225              clnt_raw_create() function should be called after
226              svc_raw_create().
227
228     clnt_tli_create()
229              This routine creates an RPC client handle for the remote program
230              prognum and version versnum.  The remote program is located at
231              address svcaddr.  If svcaddr is NULL and it is connection-ori‐
232              ented, it is assumed that the file descriptor is connected.  For
233              connectionless transports, if svcaddr is NULL, RPC_UNKNOWNADDR
234              error is set.  The fildes argument is a file descriptor which
235              may be open, bound and connected.  If it is RPC_ANYFD, it opens
236              a file descriptor on the transport specified by netconf.  If
237              fildes is RPC_ANYFD and netconf is NULL, a RPC_UNKNOWNPROTO
238              error is set.  If fildes is unbound, then it will attempt to
239              bind the descriptor.  The user may specify the size of the buf‐
240              fers with the sendsz and recvsz arguments; values of 0 choose
241              suitable defaults.  Depending upon the type of the transport
242              (connection-oriented or connectionless), clnt_tli_create() calls
243              appropriate client creation routines.  This routine returns NULL
244              if it fails.  The clnt_pcreateerror() routine can be used to
245              print the reason for failure.  The remote rpcbind service (see
246              rpcbind(8)) is not consulted for the address of the remote ser‐
247              vice.
248
249     clnt_tp_create()
250              Like clnt_create() except clnt_tp_create() tries only one trans‐
251              port specified through netconf.  The clnt_tp_create() function
252              creates a client handle for the program prognum, the version
253              versnum, and for the transport specified by netconf.  Default
254              options are set, which can be changed using clnt_control()
255              calls.  The remote rpcbind service on the host host is consulted
256              for the address of the remote service.  This routine returns
257              NULL if it fails.  The clnt_pcreateerror() routine can be used
258              to print the reason for failure.
259
260     clnt_tp_create_timed()
261              Like clnt_tp_create() except clnt_tp_create_timed() has the
262              extra argument timeout which specifies the maximum time allowed
263              for the creation attempt to succeed.  In all other respects, the
264              clnt_tp_create_timed() call behaves exactly like the
265              clnt_tp_create() call.
266
267     clnt_vc_create()
268              This routine creates an RPC client for the remote program
269              prognum and version versnum; the client uses a connection-ori‐
270              ented transport.  The remote program is located at address
271              svcaddr.  The fildes argument is an open and bound file descrip‐
272              tor.  The user may specify the size of the send and receive buf‐
273              fers with the sendsz and recvsz arguments; values of 0 choose
274              suitable defaults.  This routine returns NULL if it fails.  The
275              address svcaddr should not be NULL and should point to the
276              actual address of the remote program.  The clnt_vc_create()
277              function does not consult the remote rpcbind service for this
278              information.
279
280     struct rpc_createerr rpc_createerr;
281              A global variable whose value is set by any RPC client handle
282              creation routine that fails.  It is used by the routine
283              clnt_pcreateerror() to print the reason for the failure.
284

SEE ALSO

286     rpc(3), rpc_clnt_auth(3), rpc_clnt_calls(3), rpcbind(8)
287
288BSD                               May 7, 1993                              BSD
Impressum