clnt_tp_create()--Create a Client Handle


  Syntax

 #include <rpc/rpc.h>
 #include <netconfig.h>

 CLIENT *clnt_tp_create(const char *host,
                        const u_long prognum,
                        const u_long versnum,
                        const struct netconfig
                            *netconf);

  Service Program Name: QZNFTRPC

  Default Public Authority: *USE

  Threadsafe: No

The clnt_tp_create() API creates a client handle for the program prognum, the version versnum, and for the transport specified by netconf. The remote RPCBind service on the host machine host is consulted for the address of the remote service.


Parameters

host  (Input) 
The name of the remote host where the server is located.

prognum  (Input) 
The program number of the remote program.

vernum  (Input) 
The version number of the remote program.

netconf  (Input) 
The transport protocol to use.

Authorities

The caller of the clnt_tp_create() API must have execute (*X) authority to the /etc directory and must have read (*R) authority to the netconfig file.


Return Value



Error Conditions

Upon failure, clnt_tp_create() sets the global structure rpc_createerr. The rpc_createerr.cf_stat variable contains a status value that indicates the error reason. The rpc_createerr.cf_error.re_errno variable is meaningful when some status values are set.

The rpc_createerr.cf_stat variable can be set to one of the following values:



Error Messages



Related Information


Example

The following example shows how clnt_tp_create() is used.

Note: By using the code examples, you agree to the terms of the Code license and disclaimer information.

/* Define remote program number and version */
#define RMTPROGNUM ((u_long)0x3fffffff)
#define RMTPROGVER ((u_long)0x1)

#include <stdio.h>
#include <rpc/rpc.h>
#include <netconfig.h>
#include <netdir.h>

main()
{
  CLIENT *client;
  struct netconfig *nconf;

  /* Returns a pointer to nconf corresponding to NETCONF */
  if ((nconf = getnetconfigent("UDP")) ==
               (struct netconfig *)NULL) {
    fprintf(stderr, "Cannot get netconfig entry for UDP\n");
    exit(1);
  }

  client = clnt_tp_create("as400.somewhere.ibm.com", RMTPROGNUM,
                                     RMTPROGVER, nconf);
  if (client == (CLIENT *)NULL) {
    fprintf(stderr, "Cannot create an RPC client\n");
    exit(1);
  }

  fprintf(stderr, "Successfully created a client handle\n"); 

  clnt_destroy(client);
}


API introduced: V4R2

[ Back to top | Remote Procedure Call (RPC) APIs | APIs by category ]