Creates and returns a generic client handle for a remote program and the registered version number that is the highest within the specified range.
Network Services Library (libnsl.a)
#include <rpc/rpc.h>
 clnt_create_vers(host, prognum, progver_out, progver_low, progver_high, nettype)
const char *host;
const rpcprog_t prognum;
rpcvers_t *progver_out;
const rpcvers_t progver_low;
const rpcvers_t progver_high;
const char *nettype;
| Item | Description | 
|---|---|
| host | Specifies the host name where the server resides. | 
| prognum | Specifies the program number of the remote program. | 
| versnum | Specifies the version number of the remote program. | 
| progver_out | The highest version number that is registered at the server. The version number is returned within the specified range. | 
| progver_low | The lower limit of the version number specified by the application. | 
| progver_high | The upper limit of the version number specified by the application. | 
| nettype | Defines a class of transports that can be used for a particular application. | 
| Item | Description | 
|---|---|
| a generic client handle that is valid | successful | 
| a null value | unsuccessful | 
The clnt_create_vers subroutine returns failure when one or more of the following codes are true.
| Item | Description | 
|---|---|
| RPC_UNKNOWNPROTO |  
  | 
| RPC_UNKNOWNHOST | The host name is not valid. | 
| RPC_PROGVERSMISMATCH | No version is registered at the server within the range bounded by the values specified by the progver_low and progver_high parameters. | 
| RPC_PROGNOTREGISTERED | The program number is not valid. | 
#include <stdlib.h>
#include <rpc/rpc.h>
int main()
{
    CLIENT *cl;
    rpcprog_t PROGNUM = 0x3fffffffL;
    rpcvers_t PROGVER_OUT ;
    char *nettype = "visible";
    rpcvers_t PROGVER_LOW = 1;
    rpcvers_t PROGVER_HIGH = 10;
    char hostname[255]; /* The Remote host on which the server resides */
    /*
    * make the clnt_create_vers call with this nettype and
    * observe the result
    */
    if ((cl=clnt_create_vers( hostname, PROGNUM, &PROGVER_OUT,
                   PROGVER_LOW, PROGVER_HIGH, nettype)) == NULL)
    {
         fprintf(stdout, "clnt_create_vers : failed.\n");
         exit(EXIT_FAILURE);
    }
    /* 
     * Make a call to clnt_call() subroutine 
     */
    /* Destroy the client handle at the end */
    clnt_destroy(cl);
     return 0;
}