1 .\" @(#)rpc_clnt_create.3n 1.36 93/08/31 SMI; from SVr4
2 .\" Copyright 1989 AT&T
3 .\" @(#)rpc_clnt_create 1.5 89/07/24 SMI;
4 .\" Copyright (c) 1988 Sun Microsystems, Inc. - All Rights Reserved.
5 .\" $NetBSD: rpc_clnt_create.3,v 1.2 2000/06/20 00:53:08 fvdl Exp $
6 .\" $FreeBSD: src/lib/libc/rpc/rpc_clnt_create.3,v 1.12 2003/09/14 13:41:56 ru Exp $
14 .Nm clnt_create_timed ,
15 .Nm clnt_create_vers ,
16 .Nm clnt_create_vers_timed ,
19 .Nm clnt_pcreateerror ,
21 .Nm clnt_spcreateerror ,
24 .Nm clnt_tp_create_timed ,
27 .Nd "library routines for dealing with creation and manipulation of"
33 .Fn clnt_control "CLIENT *clnt" "const u_int req" "char *info"
35 .Fn clnt_create "const char * host" "const rpcprog_t prognum" "const rpcvers_t versnum" "const char *nettype"
37 .Fn clnt_create_timed "const char * host" "const rpcprog_t prognum" "const rpcvers_t versnum" "const char *nettype" "const struct timeval *timeout"
39 .Fn clnt_create_vers "const char * host" "const rpcprog_t prognum" "rpcvers_t *vers_outp" "const rpcvers_t vers_low" "const rpcvers_t vers_high" "const char *nettype"
41 .Fn clnt_create_vers_timed "const char * host" "const rpcprog_t prognum" "rpcvers_t *vers_outp" "const rpcvers_t vers_low" "const rpcvers_t vers_high" "char *nettype" "const struct timeval *timeout"
43 .Fn clnt_destroy "CLIENT *clnt"
45 .Fn clnt_dg_create "const int fildes" "const struct netbuf *svcaddr" "const rpcprog_t prognum" "const rpcvers_t versnum" "const u_int sendsz" "const u_int recvsz"
47 .Fn clnt_pcreateerror "const char *s"
49 .Fn clnt_spcreateerror "const char *s"
51 .Fn clnt_raw_create "const rpcprog_t prognum" "const rpcvers_t versnum"
53 .Fn clnt_tli_create "const int fildes" "const struct netconfig *netconf" "const struct netbuf *svcaddr" "const rpcprog_t prognum" "const rpcvers_t versnum" "const u_int sendsz" "const u_int recvsz"
55 .Fn clnt_tp_create "const char * host" "const rpcprog_t prognum" "const rpcvers_t versnum" "const struct netconfig *netconf"
57 .Fn clnt_tp_create_timed "const char * host" "const rpcprog_t prognum" "const rpcvers_t versnum" "const struct netconfig *netconf" "const struct timeval *timeout"
59 .Fn clnt_vc_create "const int fildes" "const struct netbuf *svcaddr" "const rpcprog_t prognum" "const rpcvers_t versnum" "u_int sendsz" "u_int recvsz"
61 RPC library routines allow C language programs to make procedure
62 calls on other machines across the network.
65 handle is created and then the client calls a procedure to send a
66 request to the server.
67 On receipt of the request, the server calls a dispatch routine
68 to perform the requested service, and then sends a reply.
70 .Bl -tag -width YYYYYYY
72 A function macro to change or retrieve various information
73 about a client object.
77 indicates the type of operation, and
79 is a pointer to the information.
80 For both connectionless and connection-oriented transports,
81 the supported values of
83 and their argument types and what they do are:
84 .Bl -column "CLSET_FD_NCLOSE" "struct timeval *" "set total timeout"
85 .It Dv CLSET_TIMEOUT Ta "struct timeval *" Ta "set total timeout"
86 .It Dv CLGET_TIMEOUT Ta "struct timeval *" Ta "get total timeout"
90 if you set the timeout using
92 the timeout argument passed by
94 is ignored in all subsequent calls.
97 If you set the timeout value to 0,
99 immediately returns an error
100 .Pq Dv RPC_TIMEDOUT .
101 Set the timeout argument to 0 for batching calls.
102 .Bl -column CLSET_FD_NCLOSE "struct timeval *" "do not close fd on destroy"
103 .It Dv CLGET_SVC_ADDR Ta "struct netbuf *" Ta "get servers address"
104 .It Dv CLGET_FD Ta "int *" Ta "get fd from handle"
105 .It Dv CLSET_FD_CLOSE Ta "void" Ta "close fd on destroy"
106 .It Dv CLSET_FD_NCLOSE Ta void Ta "don't close fd on destroy"
107 .It Dv CLGET_VERS Ta "u_int32_t *" Ta "get RPC program version"
108 .It Dv CLSET_VERS Ta "u_int32_t *" Ta "set RPC program version"
109 .It Dv CLGET_XID Ta "u_int32_t *" Ta "get XID of previous call"
110 .It Dv CLSET_XID Ta "u_int32_t *" Ta "set XID of next call"
113 The following operations are valid for connectionless transports only:
114 .Bl -column CLSET_RETRY_TIMEOUT "struct timeval *" "set total timeout"
115 .It Dv CLSET_RETRY_TIMEOUT Ta "struct timeval *" Ta "set the retry timeout"
116 .It Dv CLGET_RETRY_TIMEOUT Ta "struct timeval *" Ta "get the retry timeout"
117 .It Dv CLSET_CONNECT Ta Vt "int *" Ta use Xr connect 2
120 The retry timeout is the time that RPC
121 waits for the server to reply before retransmitting the request.
131 Generic client creation routine for program
138 identifies the name of the remote host where the server
143 indicates the class of transport protocol to use.
144 The transports are tried in left to right order in
146 environment variable or in top to bottom order in
147 the netconfig database.
151 tries all the transports of the
153 class available from the
155 environment variable and the netconfig database,
156 and chooses the first successful one.
157 A default timeout is set and can be modified using
163 .Fn clnt_pcreateerror
164 routine can be used to print the reason for failure.
168 returns a valid client handle even
169 if the particular version number supplied to
171 is not registered with the
174 This mismatch will be discovered by a
177 .Xr rpc_clnt_calls 3 ) .
178 .It Fn clnt_create_timed
179 Generic client creation routine which is similar to
181 but which also has the additional argument
183 that specifies the maximum amount of time allowed for
184 each transport class tried.
185 In all other respects, the
186 .Fn clnt_create_timed
187 call behaves exactly like the
190 .It Fn clnt_create_vers
191 Generic client creation routine which is similar to
193 but which also checks for the
194 version availability.
198 identifies the name of the remote host where the server
203 indicates the class transport protocols to be used.
204 If the routine is successful it returns a client handle created for
205 the highest version between
209 that is supported by the server.
213 is set to this value.
214 That is, after a successful return
220 If no version between
224 is supported by the server then the routine fails and returns
226 A default timeout is set and can be modified using
232 .Fn clnt_pcreateerror
233 routine can be used to print the reason for failure.
236 returns a valid client handle even
237 if the particular version number supplied to
239 is not registered with the
242 This mismatch will be discovered by a
245 .Xr rpc_clnt_calls 3 ) .
248 does this for you and returns a valid handle
249 only if a version within
250 the range supplied is supported by the server.
251 .It Fn clnt_create_vers_timed
252 Generic client creation routine which is similar to
254 but which also has the additional argument
256 that specifies the maximum amount of time allowed for
257 each transport class tried.
258 In all other respects, the
259 .Fn clnt_create_vers_timed
260 call behaves exactly like the
264 A function macro that destroys the client's RPC handle.
265 Destruction usually involves deallocation
266 of private data structures, including
271 is undefined after calling
273 If the RPC library opened the associated file descriptor, or
277 the file descriptor will be closed.
278 The caller should call
279 .Fn auth_destroy "clnt->cl_auth"
282 to destroy the associated
285 .Xr rpc_clnt_auth 3 ) .
286 .It Fn clnt_dg_create
287 This routine creates an RPC client for the remote program
291 the client uses a connectionless transport.
292 The remote program is located at address
297 is an open and bound file descriptor.
298 This routine will resend the call message in intervals of
299 15 seconds until a response is received or until the
301 The total time for the call to time out is specified by
306 .Xr rpc_clnt_calls 3 ) .
307 The retry time out and the total time out periods can
310 The user may set the size of the send and receive
316 values of 0 choose suitable defaults.
320 .It Fn clnt_pcreateerror
321 Print a message to standard error indicating
322 why a client RPC handle could not be created.
323 The message is prepended with the string
325 and a colon, and appended with a newline.
326 .It Fn clnt_spcreateerror
328 .Fn clnt_pcreateerror ,
329 except that it returns a string
330 instead of printing to the standard error.
331 A newline is not appended to the message in this case.
333 returns a pointer to a buffer that is overwritten
335 .It Fn clnt_raw_create
336 This routine creates an RPC
337 client handle for the remote program
341 The transport used to pass messages to the service is
342 a buffer within the process's address space,
343 so the corresponding RPC
344 server should live in the same address space;
348 .Xr rpc_svc_create 3 ) .
349 This allows simulation of RPC and measurement of
350 RPC overheads, such as round trip times,
351 without any kernel or networking interference.
358 should be called after
360 .It Fn clnt_tli_create
361 This routine creates an RPC
362 client handle for the remote program
366 The remote program is located at address
372 and it is connection-oriented, it is assumed that the file descriptor
374 For connectionless transports, if
383 is a file descriptor which may be open, bound and connected.
386 it opens a file descriptor on the transport specified by
401 is unbound, then it will attempt to bind the descriptor.
402 The user may specify the size of the buffers with the
407 values of 0 choose suitable defaults.
408 Depending upon the type of the transport (connection-oriented
411 calls appropriate client creation routines.
416 .Fn clnt_pcreateerror
417 routine can be used to print the reason for failure.
421 is not consulted for the address of the remote
423 .It Fn clnt_tp_create
428 tries only one transport specified through
433 creates a client handle for the program
437 and for the transport specified by
439 Default options are set,
440 which can be changed using
443 The remote rpcbind service on the host
445 is consulted for the address of the remote service.
450 .Fn clnt_pcreateerror
451 routine can be used to print the reason for failure.
452 .It Fn clnt_tp_create_timed
456 .Fn clnt_tp_create_timed
457 has the extra argument
459 which specifies the maximum time allowed for
460 the creation attempt to succeed.
461 In all other respects, the
462 .Fn clnt_tp_create_timed
463 call behaves exactly like the
466 .It Fn clnt_vc_create
467 This routine creates an RPC
468 client for the remote program
472 the client uses a connection-oriented transport.
473 The remote program is located at address
478 is an open and bound file descriptor.
479 The user may specify the size of the send and receive buffers
485 values of 0 choose suitable defaults.
493 and should point to the actual address of the remote program.
497 does not consult the remote rpcbind service for this information.
499 .Vt "struct rpc_createerr" Va rpc_createerr ;
501 A global variable whose value is set by any RPC
502 client handle creation routine
504 It is used by the routine
505 .Fn clnt_pcreateerror
506 to print the reason for the failure.
509 These functions are part of libtirpc.
512 .Xr rpc_clnt_auth 3 ,
513 .Xr rpc_clnt_calls 3 ,