Creates a client handle and returns its address. Seeks to use a server supporting the highest version number within a specified range. Format #include <rpc/rpc.h> CLIENT *clnt_create_vers(char *host, u_long prognum, u_long *versnum, u_long min_vers, u_long max_vers, char *protocol);
1 – Arguments
host A pointer to the name of the remote host. prognum The program number associated with the remote procedure. versnum The version number associated with the remote procedure. This value is returned by the routine. The value is the highest version number supported by the remote server that is in the range of version numbers specified by min_vers and max_vers. The argument may remain undefined; see additional information in the Description section. min_vers The minimum acceptable version number for the remote procedure. max_vers The maximum acceptable version number for the remote procedure. protocol A pointer to a string containing the name of the protocol for transmitting and receiving RPC messages. Specify either tcp or udp.
2 – Description
The clnt_create_vers routine creates an RPC client handle for prognum. An RPC client handle is a structure containing information about the RPC client. The client can use the UDP or TCP transport protocol. This routine uses the Portmapper. You cannot control the local port. The default sizes of the send and receive buffers are 8800 bytes for the UDP transport, and 4000 bytes for the TCP transport. The retry time for the UDP transport is 5 seconds. The clnt_create_vers routine differs from the standard clnt_ create routine in that it seeks out the highest version number supported by the server. If the server does not support any version numbers within the requested range, the routine returns NULL and the versnum variable is undefined. The clnt_create_vers routine uses the global variable rpc_ createerr. rpc_createerr is a structure that contains the most recent service creation error. Use rpc_createerr if you want the client program to handle the error. The value of rpc_createerr is set by any RPC client creation routine that does not succeed.
3 – Return Values
CLIENT * Clien-thandle containing the server information. NULL Error occurred while creating the client handle. Usually the error indicates that the server does not support any version numbers within the requested range. Use the clnt_ pcreateerror or clnt_spcreateerror routine to obtain diagnostic information.