svc_unregister Subroutine

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

svc_unregister Subroutine Exported from the libc Library

Purpose

Removes mappings between procedures and objects.

Library

C Library (libc.a)

Syntax

#include <rpc/rpc.h>

void svc_unregister ( prognum,  versnum)
u_long prognum, versnum;

Description

The svc_unregister subroutine removes mappings between dispatch subroutines and the service procedure identified by the prognum parameter and the versnum parameter. It also removes the mapping between the port number and the service procedure which is identified by the prognum parameter and the versnum parameter.

Parameters

Item Description
prognum Specifies the program number of the remote program.
versnum Specifies the version number of the remote program.

svc_unregister Subroutine Exported from the libnsl Library

Purpose

Removes mappings between a service procedure and dispatch subroutines.

Library

Network Services Library (libnsl.a)

Syntax

#include <rpc/rpc.h>
void svc_unregister (prognum, versnum)
rpcprog_t prognum;
rpcvers_t versnum;

Description

The svc_unregister subroutine removes mappings between dispatch subroutines and the service procedure identified by the prognum parameter and the versnum parameter. It also removes the mapping between the port number and the triple (the program, the version, the protocol) from the portmap daemon.

The svc_unregister subroutine is obsolete. Use the svc_unreg subroutine instead.

Parameters

Item Description
prognum Specifies the program number of the remote program.
versnum Specifies the version number of the remote program.

Examples

#include <rpc/rpc.h>

rpcprog_t prognum = 0x3fffffffL;
rpcvers_t versnum = 0x1L;

static void dispatch(rqstp, transp) /* remote procedure */
struct svc_req *rqstp;
SVCXPRT *transp;
{
  /* Dispatch Routine Code */
}

void main_exit_handler()
{
  svc_unregister(prognum,versnum);
}

int main()
{
  SVCXPRT   *svc = NULL;
  uint_t     sendsz, recvsz; 
  int  protocol = IPPROTO_TCP;

  /* register exit handler which on exit of server program calls svc_unregister */
  atexit(main_exit_handler)
  
  /* Set send and recieve buffer sizes to 0 so that they are set to default values
   * when svctcp_create() is called    
   */
  sendsz = 0;
  recvsz = 0;

  /* Create service handle for tcp transport */
  svc = (SVCXPRT *) svctcp_create(RPC_ANYSOCK, sendsz, recvsz);
  if (svc == NULL) {
    fprintf(stderr, "\nsvcudp_create failed\n");
    exit(1);
  }

  if(svc_register(svc, prognum, versnum, dispatch, protocol)==0);
  {
    fprintf(stderr,"svc_register() failed");
    exit(1);
  }
  
  /* Accept client requests */
  svc_run();

  return 0;
}