svc_create()--Create a Server Handle
Syntax
#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);
Service Program Name: QZNFTRPC
Default Public Authority: *USE
Threadsafe: No
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.
Parameters
- dispatch (Input)
- The server dispatch function. dispatch is called when there is a
remote procedure call for the given prognum and versnum.
- prognum (Input)
- The program number of the remote program.
- vernum (Input)
- The version number of the remote program
- nettype (Input)
- The following classes of transport protocol are valid: NETPATH, VISIBLE, CIRCUIT_V, DATAGRAM_V, CIRCUIT_N, DATAGRAM_N, TCP, and UDP.
Authorities
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.
Return Value
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. |
Error Conditions
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.
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. |
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. |
Related Information
Example
The following example shows how svc_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)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) { ... }
API introduced: V4R2
[ Back to top | Remote Procedure Call (RPC) APIs | APIs by category ]