rpc_reg()--Register a Procedure with RPC Service Package


  Syntax

 =
 #include <rpc/rpc.h>

 bool_t rpc_reg(const u_long prognum,
                const u_long versnum,
                const u_long procnum,
                char *(*procname)(char *),
                const xdrproc_t inproc,
                const xdrproc_t outproc,
                const char *nettype);

  Service Program Name: QZNFTRPC

  Default Public Authority: *USE

  Threadsafe: No

The rpc_reg() function registers a procedure with the RPC service package (RPCBind). If a request arrives that matches the values of the prognum parameter, the versnum parameter, and the procnum parameter, then the procname parameter is called with a pointer to its parameters. The procname returns a pointer to its static results.

The procedure is registered for each transport of the specified type (the nettype parameter). If the nettype parameter is (char *)NULL, the procedure is registered for all transports that are specified in the /etc/netconfig file with a corresponding flag value visible. After registering the local procedure, the server program's main procedure calls svc_run(), the RPC library's remote procedure dispatcher.


Parameters

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

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

procnum  (Input) 
The procedure number to be called.

procname  (Input) 
The procedure name.

inproc  (Input) 
The eXternal Data Representation (XDR) subroutine that decodes the procedure parameters.

outproc  (Input) 
The XDR subroutine that encodes the procedure results.

nettype  (Input) 
The following classes of transport protocol are valid and are represented as a string either in lowercase or in uppercase: NETPATH, VISIBLE, CIRCUIT_V, DATAGRAM_V, CIRCUIT_N, DATAGRAM_N, TCP, AND UDP. When this parameter is NULL, NETPATH is assumed.

Authorities

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


Return Value

TRUE (1) rpc_reg() was successful.
FALSE (0) rpc_reg() was not successful. The errno variable is set to indicate the reason.


Error Conditions

This API inherits all error conditions from the setnetconfig() and getnetconfig() APIs. It also inherits all error conditions from the svc_tli_create() and svc_reg() APIs.


Error Messages

Message ID Error Message Text
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.
CPIA1B2 I TI-RPC encountered a problem in the transport protocol.
CPIA1B3 I TI-RPC encountered a problem in the server.
CPIA1B5 I An incorrect nettype was given.


Related Information


Example

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

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

int *rmtproc(int *param) /* remote procedure */
{
  static int result;
  result = *param + *param;
  return(&result);
}

main()
{
  int *rmtprog();

  /* Register remote program with RPCBind */
  if (rpc_reg(RMTPROGNUM, RMTPROGVER, RMTPROCNUM, rmtprog,
                         xdr_int, xdr_int, "VISIBLE") == -1) {
    fprintf(stderr, "Could not Register\n");
    exit(1);
  }
  svc_run();
  exit(1);
}


API introduced: V4R2

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