svc_control Subroutine

Purpose

Retrieves information about a client call (a server-side routine).

Library

Network Services Library (libnsl.a)

Syntax

#include <rpc/rpc.h>
bool_t svc_control(svc, rq, in);
SVCXPRT *svc;
u_int rq;
void *in;

Description

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.

Parameters

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:
SVCGET_XID
This operation returns transaction ID of a client call. The transaction ID uniquely identifies a client request with the version, program number, procedure number and client. The transaction ID is retrieved from the RPC service handle. Only the RPC service handle of a connection-oriented or connectionless transport has transaction ID. For other handles, the function returns false.
in Points to information that can be retrieved.

Return Values

Item Description
TRUE successful
FALSE unsuccessful

Examples

#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);
     }

}