svc_destroy Macro

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

svc_destroy Macro Exported from the libc Library

Purpose

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

Library

C Library (libc.a)

Syntax

#include <rpc/rpc.h>

void svc_destroy ( xprt)
SVCXPRT *xprt;

Description

The svc_destroy macro destroys an RPC service transport handle. Destroying the service transport handle deallocates the private data structures, including the handle itself. After the svc_destroy macro is used, the handle pointed to by the xprt parameter is no longer defined.

Parameters

Item Description
xprt Points to the RPC service transport handle.

svc_destroy Macro Exported from the libnsl Library

Purpose

Destroys a remote procedure call (RPC) service handle.

Library

Network Services Library (libnsl.a)

Syntax

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

Description

This subroutine is a top-level API for transport-independent remote procedure calls (TI_PRC), giving you greater control over communication parameters. This subroutine destroys the RPC service handle that is created when registering the service. This subroutine deallocates all of the private data structures that are allocated when the handle is created and the handle itself.

Parameters

Item Description
xprt Points to the RPC service 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; 
     int fd;
     struct netconfig *nconf; 

     /* Get required file descriptor, and transport type */

     /* Create RPC service handle */
     if((svc_handle = svc_tli_create(fd, nconf, 0, 0, 0)) == (SVCXPRT *)NULL)
     {
          fprintf(stdout,"Error in svc_tli_create!");
          exit(EXIT_FAILURE);
     }
  
     /* Register RPC service using RPC service handle with RPCBIND package*/
     if(svc_reg(svc_handle, PROG, VERS, sample_dispatch, nconf) == 0)
     {
          fprintf(stdout,"Error in svc_reg!");
                 
          /*Destroy the RPC service handle as service is not registered*/
          svc_destroy(svc_handle);
          exit(EXIT_FAILURE);
      }
           
      svc_run();
      return 0;
      }
/* following is the sample dispatch routine*/
static void sample_dispatch(struct svc_req *request, SVCXPRT *xprt)
{
         /*   dispatch routine code  */

}