xprt_register Subroutine

Important: The subroutine is exported from both the libc and libnsl libraries.

xprt_register Subroutine Exported from the libc Library

Purpose

Registers a Remote Procedure Call (RPC) service transport handle.

Library

C Library (libc.a)

Syntax

#include <rpc/svc.h>
void xprt_register ( xprt)
SVCXPRT *xprt;

Description

The xprt_register subroutine registers an RPC service transport handle with the RPC program after the transport has been created. This subroutine modifies the svc_fdset global variable. The svc_fdset global variable indicates read file descriptor bit mask of the RPC server, which is generally required if you call the svc_exit subroutine. After calling the svc_exit subroutine , you can use the xprt_register subroutine to reregister RPC services.

Note: Service implementors do not usually need this subroutine.

Parameters

Item Description
xprt Points to the newly created RPC service transport handle.

xprt_register Subroutine Exported from the libnsl Library

Purpose

Registers a Remote Procedure Call (RPC) service transport handle.

Library

Network Services Library (libnsl.a)

Syntax

#include <rpc/rpc.h>
void xprt_register ( xprt )
const SVCXPRT *xprt;

Description

The xprt_register subroutine registers an RPC service transport handle with the RPC program after the transport has been created. This subroutine modifies the svc_fdset global variable. The svc_fdset global variable indicates read file descriptor bit mask of the RPC server, which is generally required if you call the svc_exit subroutine. After calling the svc_exit subroutine, you can use the xprt_register subroutine to reregister RPC services.

Note: Service implementors do not usually need this subroutine.

Parameters

Item Description
xprt Points to the newly created RPC service transport handle.

Examples

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


#define PROG 0x3fffffffL
#define VERS 0x1L

static void sample_dispatch();

main()
{
  
    SVCXPRT *svc_handle;
    struct netconfig *nconf;

    /* Get transport type and create RPC service handle */
                         
    /* Register dispatch routine for program number and version number with RPCBIND service */

    If(svc_reg(svc_handle, PROG, VERS, sample_dispatch,nconf) == 0)
    {
        fprintf(stdout,"Error in svc_reg!");
        exit(EXIT_FAILURE);
    }

    svc_run();
      
    /* execution control will come here after svc_exit() is called.
    Thus when client request comes, control goes in dispatch routine where svc_exit() is called. */
    
    /* code to get new svc_handle */

    /* register with xprt_register */
    xprt_register(svc_handle);
 
    /* verify if svc_fdset is modified */
     
    return 0;
}

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