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.15 2006/09/17 21:27:34 ru Exp $
15 .Nm clnt_create_timed ,
16 .Nm clnt_create_vers ,
17 .Nm clnt_create_vers_timed ,
20 .Nm clnt_pcreateerror ,
22 .Nm clnt_spcreateerror ,
25 .Nm clnt_tp_create_timed ,
28 .Nd "library routines for dealing with creation and manipulation of"
36 .Fn clnt_control "CLIENT *clnt" "const u_int req" "char *info"
38 .Fn clnt_create "const char * host" "const rpcprog_t prognum" "const rpcvers_t versnum" "const char *nettype"
40 .Fn clnt_create_timed "const char * host" "const rpcprog_t prognum" "const rpcvers_t versnum" "const char *nettype" "const struct timeval *timeout"
42 .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"
44 .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" "const char *nettype" "const struct timeval *timeout"
46 .Fn clnt_destroy "CLIENT *clnt"
48 .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"
50 .Fn clnt_pcreateerror "const char *s"
52 .Fn clnt_spcreateerror "const char *s"
54 .Fn clnt_raw_create "const rpcprog_t prognum" "const rpcvers_t versnum"
56 .Fn clnt_tli_create "const int fildes" "const struct netconfig *netconf" "struct netbuf *svcaddr" "const rpcprog_t prognum" "const rpcvers_t versnum" "const u_int sendsz" "const u_int recvsz"
58 .Fn clnt_tp_create "const char * host" "const rpcprog_t prognum" "const rpcvers_t versnum" "const struct netconfig *netconf"
60 .Fn clnt_tp_create_timed "const char * host" "const rpcprog_t prognum" "const rpcvers_t versnum" "const struct netconfig *netconf" "const struct timeval *timeout"
62 .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"
64 RPC library routines allow C language programs to make procedure
65 calls on other machines across the network.
68 handle is created and then the client calls a procedure to send a
69 request to the server.
70 On receipt of the request, the server calls a dispatch routine
71 to perform the requested service, and then sends a reply.
73 .Bl -tag -width YYYYYYY
75 A function macro to change or retrieve various information
76 about a client object.
80 indicates the type of operation, and
82 is a pointer to the information.
83 For both connectionless and connection-oriented transports,
84 the supported values of
86 and their argument types and what they do are:
87 .Bl -column "CLSET_FD_NCLOSE" "struct timeval *" "set total timeout"
88 .It Dv CLSET_TIMEOUT Ta "struct timeval *" Ta "set total timeout"
89 .It Dv CLGET_TIMEOUT Ta "struct timeval *" Ta "get total timeout"
93 if you set the timeout using
95 the timeout argument passed by
97 is ignored in all subsequent calls.
100 If you set the timeout value to 0,
102 immediately returns an error
103 .Pq Dv RPC_TIMEDOUT .
104 Set the timeout argument to 0 for batching calls.
105 .Bl -column CLSET_FD_NCLOSE "struct timeval *"
106 .It Dv CLGET_SVC_ADDR Ta "struct netbuf *" Ta "get servers address"
107 .It Dv CLGET_FD Ta "int *" Ta "get fd from handle"
108 .It Dv CLSET_FD_CLOSE Ta "void" Ta "close fd on destroy"
109 .It Dv CLSET_FD_NCLOSE Ta void Ta "do not close fd on destroy"
110 .It Dv CLGET_VERS Ta "u_int32_t *" Ta "get RPC program version"
111 .It Dv CLSET_VERS Ta "u_int32_t *" Ta "set RPC program version"
112 .It Dv CLGET_XID Ta "u_int32_t *" Ta "get XID of previous call"
113 .It Dv CLSET_XID Ta "u_int32_t *" Ta "set XID of next call"
116 The following operations are valid for connectionless transports only:
117 .Bl -column CLSET_RETRY_TIMEOUT "struct timeval *" "set total timeout"
118 .It Dv CLSET_RETRY_TIMEOUT Ta "struct timeval *" Ta "set the retry timeout"
119 .It Dv CLGET_RETRY_TIMEOUT Ta "struct timeval *" Ta "get the retry timeout"
120 .It Dv CLSET_CONNECT Ta Vt "int *" Ta use Xr connect 2
123 The retry timeout is the time that RPC
124 waits for the server to reply before retransmitting the request.
134 Generic client creation routine for program
141 identifies the name of the remote host where the server
146 indicates the class of transport protocol to use.
147 The transports are tried in left to right order in
149 environment variable or in top to bottom order in
150 the netconfig database.
154 tries all the transports of the
156 class available from the
158 environment variable and the netconfig database,
159 and chooses the first successful one.
160 A default timeout is set and can be modified using
166 .Fn clnt_pcreateerror
167 routine can be used to print the reason for failure.
171 returns a valid client handle even
172 if the particular version number supplied to
174 is not registered with the
177 This mismatch will be discovered by a
180 .Xr rpc_clnt_calls 3 ) .
181 .It Fn clnt_create_timed
182 Generic client creation routine which is similar to
184 but which also has the additional argument
186 that specifies the maximum amount of time allowed for
187 each transport class tried.
188 In all other respects, the
189 .Fn clnt_create_timed
190 call behaves exactly like the
193 .It Fn clnt_create_vers
194 Generic client creation routine which is similar to
196 but which also checks for the
197 version availability.
201 identifies the name of the remote host where the server
206 indicates the class transport protocols to be used.
207 If the routine is successful it returns a client handle created for
208 the highest version between
212 that is supported by the server.
216 is set to this value.
217 That is, after a successful return
223 If no version between
227 is supported by the server then the routine fails and returns
229 A default timeout is set and can be modified using
235 .Fn clnt_pcreateerror
236 routine can be used to print the reason for failure.
239 returns a valid client handle even
240 if the particular version number supplied to
242 is not registered with the
245 This mismatch will be discovered by a
248 .Xr rpc_clnt_calls 3 ) .
251 does this for you and returns a valid handle
252 only if a version within
253 the range supplied is supported by the server.
254 .It Fn clnt_create_vers_timed
255 Generic client creation routine which is similar to
257 but which also has the additional argument
259 that specifies the maximum amount of time allowed for
260 each transport class tried.
261 In all other respects, the
262 .Fn clnt_create_vers_timed
263 call behaves exactly like the
267 A function macro that destroys the client's RPC handle.
268 Destruction usually involves deallocation
269 of private data structures, including
274 is undefined after calling
276 If the RPC library opened the associated file descriptor, or
280 the file descriptor will be closed.
281 The caller should call
282 .Fn auth_destroy "clnt->cl_auth"
285 to destroy the associated
288 .Xr rpc_clnt_auth 3 ) .
289 .It Fn clnt_dg_create
290 This routine creates an RPC client for the remote program
294 the client uses a connectionless transport.
295 The remote program is located at address
300 is an open and bound file descriptor.
301 This routine will resend the call message in intervals of
302 15 seconds until a response is received or until the
304 The total time for the call to time out is specified by
309 .Xr rpc_clnt_calls 3 ) .
310 The retry time out and the total time out periods can
313 The user may set the size of the send and receive
319 values of 0 choose suitable defaults.
323 .It Fn clnt_pcreateerror
324 Print a message to standard error indicating
325 why a client RPC handle could not be created.
326 The message is prepended with the string
328 and a colon, and appended with a newline.
329 .It Fn clnt_spcreateerror
331 .Fn clnt_pcreateerror ,
332 except that it returns a string
333 instead of printing to the standard error.
334 A newline is not appended to the message in this case.
336 returns a pointer to a buffer that is overwritten
338 .It Fn clnt_raw_create
339 This routine creates an RPC
340 client handle for the remote program
344 The transport used to pass messages to the service is
345 a buffer within the process's address space,
346 so the corresponding RPC
347 server should live in the same address space;
351 .Xr rpc_svc_create 3 ) .
352 This allows simulation of RPC and measurement of
353 RPC overheads, such as round trip times,
354 without any kernel or networking interference.
361 should be called after
363 .It Fn clnt_tli_create
364 This routine creates an RPC
365 client handle for the remote program
369 The remote program is located at address
375 and it is connection-oriented, it is assumed that the file descriptor
377 For connectionless transports, if
386 is a file descriptor which may be open, bound and connected.
389 it opens a file descriptor on the transport specified by
404 is unbound, then it will attempt to bind the descriptor.
405 The user may specify the size of the buffers with the
410 values of 0 choose suitable defaults.
411 Depending upon the type of the transport (connection-oriented
414 calls appropriate client creation routines.
419 .Fn clnt_pcreateerror
420 routine can be used to print the reason for failure.
424 is not consulted for the address of the remote
426 .It Fn clnt_tp_create
431 tries only one transport specified through
436 creates a client handle for the program
440 and for the transport specified by
442 Default options are set,
443 which can be changed using
446 The remote rpcbind service on the host
448 is consulted for the address of the remote service.
453 .Fn clnt_pcreateerror
454 routine can be used to print the reason for failure.
455 .It Fn clnt_tp_create_timed
459 .Fn clnt_tp_create_timed
460 has the extra argument
462 which specifies the maximum time allowed for
463 the creation attempt to succeed.
464 In all other respects, the
465 .Fn clnt_tp_create_timed
466 call behaves exactly like the
469 .It Fn clnt_vc_create
470 This routine creates an RPC
471 client for the remote program
475 the client uses a connection-oriented transport.
476 The remote program is located at address
481 is an open and bound file descriptor.
482 The user may specify the size of the send and receive buffers
488 values of 0 choose suitable defaults.
496 and should point to the actual address of the remote program.
500 does not consult the remote rpcbind service for this information.
502 .Vt "struct rpc_createerr" Va rpc_createerr ;
504 A global variable whose value is set by any RPC
505 client handle creation routine
507 It is used by the routine
508 .Fn clnt_pcreateerror
509 to print the reason for the failure.
513 .Xr rpc_clnt_auth 3 ,
514 .Xr rpc_clnt_calls 3 ,