RPC_CLNT_CREATE(3NSL) | Networking Services Library Functions | RPC_CLNT_CREATE(3NSL) |
rpc_clnt_create, clnt_control, clnt_create, clnt_create_timed, clnt_create_vers, clnt_create_vers_timed, clnt_destroy, clnt_dg_create, clnt_pcreateerror, clnt_raw_create, clnt_spcreateerror, clnt_tli_create, clnt_tp_create, clnt_tp_create_timed, clnt_vc_create, rpc_createerr, clnt_door_create - library routines for dealing with creation and manipulation of CLIENT handles
#include <rpc/rpc.h> bool_t clnt_control(CLIENT *clnt, const uint_t req, char *info);
CLIENT *clnt_create(const char *host, const rpcprog_t prognum,
const rpcvers_t versnum, const char *nettype);
CLIENT *clnt_create_timed(const char *host, const rpcprog_t prognum,
const rpcvers_t versnum, const char *nettype,
const struct timeval *timeout);
CLIENT *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);
CLIENT *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);
void clnt_destroy(CLIENT *clnt);
CLIENT *clnt_dg_create(const int fildes,
const struct netbuf *svcaddr, const rpcprog_t prognum,
const rpcvers_t versnum, const uint_t sendsz,
const uint_t recsz);
void clnt_pcreateerror(const char *s);
CLIENT *clnt_raw_create(const rpcprog_t prognum,
const rpcvers_t versnum);
char *clnt_spcreateerror(const char *s);
CLIENT *clnt_tli_create(const int fildes,
const struct netconfig *netconf, const struct netbuf *svcaddr,
const rpcprog_t prognum, const rpcvers_t versnum,
const uint_t sendsz, const uint_t recsz);
CLIENT *clnt_tp_create(const char *host,
const rpcprog_t prognum, const rpcvers_t versnum,
const struct netconfig *netconf);
CLIENT *clnt_tp_create_timed(const char *host,
const rpcprog_t prognum, const rpcvers_t versnum,
const struct netconfig *netconf, const struct timeval *timeout);
CLIENT *clnt_vc_create(const int fildes,
const struct netbuf *svcaddr, const rpcprog_t prognum,
const rpcvers_t versnum, const uint_t sendsz,
const uint_t recsz);
struct rpc_createerr rpc_createerr;
CLIENT *clnt_door_create(const rpcprog_t prognum,
const rpcvers_t versnum, const uint_t sendsz);
RPC library routines allow C language programs to make procedure calls on other machines across the network. First a CLIENT handle is created and then the client calls a procedure to send a request to the server. On receipt of the request, the server calls a dispatch routine to perform the requested service, and then sends a reply.
These routines are MT-Safe. In the case of multithreaded applications, the -mt option must be specified on the command line at compilation time. When the -mt option is specified, rpc_createerr becomes a macro that enables each thread to have its own rpc_createerr. See threads(7).
See rpc(3NSL) for the definition of the CLIENT data structure.
clnt_control()
CLSET_TIMEOUT struct timeval * set total timeout CLGET_TIMEOUT struct timeval * get total timeout
If the timeout is set using clnt_control(), the timeout argument passed by clnt_call() is ignored in all subsequent calls. If the timeout value is set to 0, clnt_control() immediately returns RPC_TIMEDOUT. Set the timeout parameter to 0 for batching calls.
CLGET_SERVER_ADDR struct netbuf * get server's address CLGET_SVC_ADDR struct netbuf * get server's address CLGET_FD int * get associated file descriptor CLSET_FD_CLOSE void close the file descriptor when destroying the client handle (see clnt_destroy()) CLSET_FD_NCLOSE void do not close the file descriptor when destroying the client handle CLGET_VERS rpcvers_t get the RPC program's version number associated with the client handle CLSET_VERS rpcvers_t set the RPC program's version number associated with the client handle. This assumes that the RPC server for this new version is still listening at the address of the previous version. CLGET_XID uint32_t get the XID of the previous remote procedure call CLSET_XID uint32_t set the XID of the next remote procedure call CLGET_PROG rpcprog_t get program number CLSET_PROG rpcprog_t set program number
The following operations are valid for connection-oriented transports only:
CLSET_IO_MODE rpciomode_t* set the IO mode used
to send one-way requests. The argument for this operation can be either:
- RPC_CL_BLOCKING all sending operations block
until the underlying transport protocol has
accepted requests. If you specify this argument
you cannot use flush and getting and setting buffer
size is meaningless.
- RPC_CL_NONBLOCKING sending operations do not
block and return as soon as requests enter the buffer.
You can now use non-blocking I/O. The requests in the buffer are pending. The requests are sent to the server as soon as a two-way request is sent or a flush is done. You are responsible for flushing the buffer. When you choose RPC_CL_NONBLOCKING argument
you have a choice of flush modes as specified by CLSET_FLUSH_MODE. CLGET_IO_MODE rpciomode_t* get the current IO mode CLSET_FLUSH_MODE rpcflushmode_t* set the flush mode.
The flush mode can only be used in non-blocking I/O mode. The argument can be either of the following: - RPC_CL_BESTEFFORT_FLUSH: All flushes send requests
in the buffer until the transport end-point blocks.
If the transport connection is congested, the call
returns directly. - RPC_CL_BLOCKING_FLUSH: Flush blocks until the
underlying transport protocol accepts all pending requests into the queue. CLGET_FLUSH_MODE rpcflushmode_t* get the current flush mode. CLFLUSH rpcflushmode_t flush the pending requests. This command can only be used in non-blocking I/O mode. The flush policy depends on which of the following parameters is specified: - RPC_CL_DEFAULT_FLUSH, or NULL: The flush is done according to the current flush mode policy (see CLSET_FLUSH_MODE option). - RPC_CL_BESTEFFORT_FLUSH: The flush tries to send pending requests without blocking; the call returns directly. If the transport connection is congested, this call could return without the request being sent. - RPC_CL_BLOCKING_FLUSH: The flush sends all pending requests. This call will block until all the requests have been accepted by the transport layer. CLSET_CONNMAXREC_SIZE int* set the buffer size.
It is not possible to dynamically resize the buffer if it contains data. The default size of the buffer is 16 kilobytes. CLGET_CONNMAXREC_SIZE int* get the current size of the buffer CLGET_CURRENT_REC_SIZE int* get the size of the pending requests stored in the buffer. Use of this command is only recommended when you are in non-blocking I/O mode. The current size of the buffer is always zero when the handle is in blocking mode as the buffer is not used in this mode.
The following operations are valid for connectionless transports only:
CLSET_RETRY_TIMEOUT struct timeval * set the retry timeout CLGET_RETRY_TIMEOUT struct timeval * get the retry timeout
The retry timeout is the time that RPC waits for the server to reply before retransmitting the request.
clnt_control() returns TRUE on success and FALSE on failure.
clnt_create()
clnt_create() tries all the transports of the nettype class available from the NETPATH environment variable and the netconfig database, and chooses the first successful one. A default timeout is set and can be modified using clnt_control(). This routine returns NULL if it fails. The clnt_pcreateerror() routine can be used to print the reason for failure.
Note that clnt_create() returns a valid client handle even if the particular version number supplied to clnt_create() is not registered with the rpcbind service. This mismatch will be discovered by a clnt_call later (see rpc_clnt_calls(3NSL)).
clnt_create_timed()
clnt_create_vers()
Note: clnt_create() returns a valid client handle even if the particular version number supplied to clnt_create() is not registered with the rpcbind service. This mismatch will be discovered by a clnt_call later (see rpc_clnt_calls(3NSL)). However, clnt_create_vers() does this for you and returns a valid handle only if a version within the range supplied is supported by the server.
clnt_create_vers_timed()
clnt_destroy()
The caller should call auth_destroy(clnt->cl_auth) (before calling clnt_destroy()) to destroy the associated AUTH structure (see rpc_clnt_auth(3NSL)).
clnt_dg_create()
clnt_pcreateerror()
clnt_raw_create()
clnt_spcreateerror()
Warning: returns a pointer to a buffer that is overwritten on each call. In multithread applications, this buffer is implemented as thread-specific data.
clnt_tli_create()
clnt_tp_create()
clnt_tp_create() creates a client handle for the program prognum, the version versnum, and for the transport specified by netconf. Default options are set, which can be changed using clnt_control() calls. The remote rpcbind service on the host host is consulted for the address of the remote service. This routine returns NULL if it fails. The clnt_pcreateerror() routine can be used to print the reason for failure.
clnt_tp_create_timed()
clnt_vc_create()
The address svcaddr should not be NULL and should point to the actual address of the remote program. clnt_vc_create() does not consult the remote rpcbind service for this information.
rpc_createerr
In multithreaded applications, rpc_createerr becomes a macro which enables each thread to have its own rpc_createerr.
clnt_door_create()
See attributes(7) for descriptions of the following attributes:
ATTRIBUTE TYPE | ATTRIBUTE VALUE |
Architecture | All |
Interface Stability | Committed |
MT-Level | MT-Safe |
rpc(3NSL), rpc_clnt_auth(3NSL), rpc_clnt_calls(3NSL), rpc_svc_create(3NSL), svc_raw_create(3NSL), attributes(7), threads(7), rpcbind(8)
July 25, 2015 | OmniOS |