=
#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);
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.
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.
| TRUE (1) | rpc_reg() was successful. |
| FALSE (0) | rpc_reg() was not successful. The errno variable is set to indicate the reason. |
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.
| 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. |
See Code disclaimer information for information pertaining to code examples.
The following example shows how rpc_reg() is used:
/* 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);
}
| Top | Remote Procedure Call (RPC) APIs | APIs by category |