Retrieves information about a client call (a server-side routine).
Network Services Library (libnsl.a)
The svc_control subroutine is a top-level subroutine for transport-independent remote procedure calls (TI_PRC), giving you greater control over communication parameters. The subroutine retrieves the transaction ID of a client call. With the RPC service handle and the operation type specified by the svc and rq parameters, the subroutine retrieves information with a pointer specified by the in parameter.
Item | Description |
---|---|
svc | Specifies the RPC service handle of a registered service. |
rq | Represents an operation type. You can specify
the SVCGET_XID operation type:
|
in | Points to information that can be retrieved. |
Item | Description |
---|---|
TRUE | successful |
FALSE | unsuccessful |
#include <stdlib.h>
#include <rpc/rpc.h>
#include <netconfig.h>
#define PROG 0x3fffffffL
#define VERS 0x1L
static void sample_dispatch();
main()
{
int in;
struct netconfig *nconf;
SVCXPRT *svc_handle;
svc_unreg(PROG, VERS);
/* Get transport type*/
nconf = getnetconfigent("tcp");
if (nconf == (struct netconfig *) NULL)
{
fprintf(stderr, "getnetconfigent failed!\n");
exit(EXIT_FAILURE);
}
/* Create RPC service handle and register with RPCBIND service */
if((svc_handle = svc_tp_create(sample_dispatch, PROG, VERS, nconf)) == (SVCXPRT *)NULL)
{
fprintf(stderr,"Error in svc_tp_create!");
exit(EXIT_FAILURE);
}
svc_run();
return 0;
}
/* following is the sample dispatch routine*/
static void sample_dispatch(struct svc_req *request, SVCXPRT *xprt)
{
int in=0;
/* dispatch routine code */
/* Retrieve the information about the registered service */
if(svc_control(xprt,SVCGET_XID,(void *)&in) == FALSE)
{
fprintf(stderr,"Error in svc_control!");
exit(EXIT_FAILURE);
}
}