#include <rpc/rpc.h> void svcerr_systemerr(const SVCXPRT *xprt);
The svcerr_systemerr() function sends information to the remote client that the service dispatch routine detected a system error not covered by any particular protocol.
No authorization is required.
None.
In case of an exception, the errno global variable is set to EUNKNOWN.
Message ID | Error Message Text |
---|---|
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 svcerr_systemerr() is used:
#include <stdio.h> #include <stdlib.h> /* getenv, exit */ #include <rpc/rpc.h> #define MESSAGEPROG ((unsigned long)(0x20000001)) #define PRINTMESSAGEVERS ((unsigned long)(1)) #define PRINTMESSAGE ((unsigned long)(1)) /* This procedure is called by dispatcher routine */ int *printmessage_l(char **msg, struct svc_req *req) { static int result; char stffl30"; int fd; /* Do something with *msg contents */ ... result = 1; return(&result); } /* This is the server dispatcher routine. It is called when a request arrives from client and it applies to MESSAGEPROG program number and PRINTMESSAGEVERS version number */ static void messageprog_l(struct svc_req *rqstp, SVCXPRT *transp) { union u_argument{ char *printmessage_l_arg; }argument; char *result; bool_t (*_xdr_argument)(), (*_xdr_result)(); char *(*local)(union u_argument *, struct svc_req *); _rpcsvccount++; switch(rqstp->rq_proc) { /* rqstp->rq_proc contains the procedure number of procedure that should be called */ case NULLPROC: /* empty procedure, do nothing, just send the ack */ svc_sendreply(transp, (xdrproc_t)xdr_void, (char *)NULL); return; case PRINTMESSAGE: /* printmessage_l() */ if (rqstp->rq_cred.oa_flavor != AUTH_SYS) { /* AUTH_SYS is required by this procedure */ svcerr_weakauth(transp); return; } _xdr_argument = (bool_t(*)())xdr_wrapstring; _xdr_result = (bool_t(*)())xdr_int; local = (char *(*)(u_argument *, struct svc_req *)) printmessage_l; break; default: /* no other procedures available */ svcerr_noproc(transp); return; } memset((char *)&argument, 0, sizeof(argument)); /* decode arguments for the procedure */ if (!svc_getargs(transp, (xdrproc_t)_xdr_argument, (char *)&argument)){ svcerr_decode(transp); return; } /* Invoke the procedure */ result = (*local)(&argument, rqstp); /* Send reply to the client containing results of the invocation */ if (result != NULL && !svc_sendreply(transp, (xdrproc_t)_xdr_result, result)){ svcerr_systemerr(transp); } if (!svc_freeargs(transp, (xdrproc_t)_xdr_argument, (char *)&argument)){ printf("unable to free arguments"); exit(1); } return; } main() { pid_t pid; int i; printf("Start.."); printf("Try to create.."); /* Create a new RPC server instance which will use messageprog_l() as a dispatcher function associated with MESSAGEPROG program number and PRINTMESSAGEVERS version number. Since "VISIBLE" nettype is selected, a number of server instances will be actually created: one for each "VISIBLE" entry in /etc/netconfig */ if(!svc_create(messageprog_l, MESSAGEPROG, PRINTMESSAGEVERS, "VISIBLE")){ printf("Unable to create service."); return 1; } /* Enter the main loop of RPC */ svc_run(); return 0; }
Top | Remote Procedure Call (RPC) APIs | APIs by category |