svc_raw_create Subroutine

Purpose

Creates a remote procedure call (RPC) handle for raw interfaces.

Library

Network Services Library (libnsl.a)

Syntax

#include <rpc/rpc.h>
SVCXPRT *svc_raw_create (void)

Description

The svc_raw_create subroutine is a bottom-level API for transport-independent remote procedure calls (TI_PRC). Bottom-level APIs provide a full control over the transport options. This subroutine creates an RPC service handle for raw interfaces. The transport type is a buffer in the address space of the process. Thus the client must be in the same address space. This subroutine provides simulation of the RPC service with all RPC overheads without actually using any network interface. This subroutine does not register a server with an RPC service package because the program number and version number are not specified.

Note: Do not use the svc_run subroutine over raw interfaces.

Return Values

Item Description
an PRC service handle successful
NULL unsuccessful

Examples

#include <stdlib.h>
#include <rpc/rpc.h>
#include <netconfig.h>

main()
{
    SVCXPRT *svc_handle;      /* server handle */

    /* create server handle using svc_raw_create */
    if((svc_handle=svc_raw_create())==(SVCXPRT *)NULL)
    {
          fprintf(stdout,"Error in svc_raw_create!");
          exit(EXIT_FAILURE);
    }

    /* Note that transport type passed to svc_reg() is NULL */  
    if(svc_reg(svc_handle, PROG, VERS, sample_dispatch, NULL) == 0)
    {
          fprintf(stdout,"Error in svc_reg!");
          exit(EXIT_FAILURE);
    }
 
    /* note that here svc_run() is not called */
    /* To call registered procedure, client should be in same address space */

    return 0;
} 
 
/* following is the sample dispatch routine*/
static void sample_dispatch(struct svc_req *request, SVCXPRT *xprt)
{
       /*   dispatch routine code  */
}