#include <rpc/rpc.h>
int svc_create(const void
(*dispatch)(const svc_req *,
const SVCXPRT *),
const u_long prognum,
const u_long versnum,
const char *nettype);
The svc_create() function creates server handles for all the transports belonging to the class nettype.
svc_create() tries all the transports of the nettype class that are available from the /etc/netconfig file in top-to-bottom order. svc_create() registers itself with the RPCBind service.
The caller of the svc_create() API must have execute (*X) authority to the /etc directory and must have read (*R) authority to the netconfig file.
| num | Upon successful completion, svc_create() returns the number of server handles it creates. |
| 0 | svc_create() was not successful. The errno variable is set to indicate the reason. |
This API calls setnetconfig() and getnetconfig() APIs in order to perform its task. The API inherits all error conditions from those APIs. It also inherits all error conditions from svc_tp_create() API except EINVAL.
| 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. |
| CPIA1B3 I | TI-RPC encountered a problem in the server. |
| CPIA1B5 I | An incorrect nettype was given. |
| 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. |
See Code disclaimer information for information pertaining to code examples.
The following example shows how svc_create() is used:
/* Define remote program number and version */
#define RMTPROGNUM (u_long)0x3fffffffL
#define RMTPROGVER (u_long)0x1
#include <stdio.h>
#include <rpc/rpc.h>
static void exm_proc();
main()
{
int transpnum;
...
transpnum = svc_create(exm_proc, RMTPROGNUM, RMTPROGVER,
"VISIBLE");
if (transpnum == 0){
fprintf(stderr, "Cannot create a service.\n");
exit(1);
}
svc_run(); /* No return */
}
/* The server dispatch function */
static void exm_proc(struct svc_req *rqstp, SVCXPRT *transp)
{
...
}
| Top | Remote Procedure Call (RPC) APIs | APIs by category |