rpcb_set()--Register the Server Address with the RPCBind


  Syntax

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

 bool_t rpcb_set(const u_long prognum,
                 const u_long versnum,
                 const struct netconfig *netconf,
                 const struct netbuf *svcaddr);

  Service Program Name: QZNFTRPC

  Default Public Authority: *USE

  Threadsafe: No

The rpcb_set() function is an interface to the RPC service package (RPCBind) daemon. The function establishes a mapping between the triple (prognum, versnum, netconf->nc_netid) and svcaddr on the machine's RPCBind service. The value of netconf->nc_netid must correspond to a network identifier that is defined by the netconfig database.


Parameters

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

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

netconf  (Input) 
The transport protocol.

svcaddr  (Input) 
A pointer to the local address of the service.

Authorities

No authorization is required.


Return Value

TRUE (1) rpcb_set was successful.
FALSE (0) rpcb_set was unsuccessful.


Error Conditions

Upon failure, rpcb_set() sets the global structure rpc_createerr. The rpc_createerr.cf_stat variable contains a status value, which 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:

[RPC_INTR] Interrupted RPC call. An exception has occurred in the RPC API. The rpc_createerr.cf_error.re_errno is set to EUNKNOWN.
[RPC_N2AXLATEFAILURE] Name to address translation failed.
[RPC_RPCBFAILURE] Unable to contact the RPCBind daemon.
[RPC_UNKNOWNADDR] Unknown address. The svcaddr is invalid.
[RPC_UNKNOWNADDR] Unknown remote address. The rpc_createerr.cf_error.re_errno variable is not applicable.
[RPC_UNKNOWNPROTO] Unknown client/server protocol. The rpc_createerr.cf_error.re_errno variable is not applicable.

This API calls clnt_tli_create() and clnt_call() APIs in order to perform its task. It inherits RPC_SYSTEMERROR from clnt_tli_create() API and it inherits all error conditions from clnt_call() API except RPC_TIMEDOUT and RPC_FAILED.


Error Messages

Message ID Error Message Text
CPIA1B1 I A problem was encountered in the RPC client.
CPIA1B2 I TI-RPC encountered a problem in the transport protocol.
CPIA1B8 I A problem occurred while trying to contact the RPCBind daemon.
CPE3418 E Possible APAR condition or hardware failure.
CPF3CF2 E Error(s) occurred during running of &1 API.
CPF9872 E Program or service program &1 in library &2 ended. Reason code &3.


Related Information


Example

The following example shows how rpcb_set() 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)0x3fffffffL
#define RMTPROGVER (u_long)0x1

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

main()
{
  struct netconfig *nconf;
  struct netbuf *svcaddr;

  ...

  /* 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);
  }

  ...

  /* Register to the RPCBind */
  if (!rpcb_set(RMTPROGNUM, RMTPROGVER, nconf, svcaddr)){
    fprintf(stderr, "rpcb_set failed!!\n");
    exit(1);
  }

  ...

}


API introduced: V4R2

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