svc_tli_create Subroutine

Purpose

Creates a remote procedure call (RPC) service handle for the specified transport.

Library

Network Services Library (libnsl.a)

Syntax

#include <rpc/rpc.h>
SVCXPRT *svc_tli_create(fd, nconf, bind_addr, sendsize, recvsize)
int fd;
const struct netconfig *nconf;
const struct  t_bind *bind_addr;
const uint_t sendsize;
const uint_t recvsize ;

Description

The subroutine is an expert-level API for transport-independent remote procedure calls (TI_PRC). This subroutine creates an RPC service handle on a given file descriptor and returns a pointer to it. The server is not registered with an RPC service package because the program and version numbers are not specified. If you specify the fd parameter with the RPC_ANYFD value, the file descriptor on the specified transport is opened. If the file descriptor is open but unbound, and you specify the bind_addr parameter with a valid address, the file descriptor is bound by the given address. If the file descriptor is open and unbound, and the value of the bind_addr parameter is NULL, the default address for the transport is used and the number of connections for the connection-oriented transport is set to 8.

Parameters

Item Description
fd Indicates an open file descriptor that is bound or unbound.
nconf Indicates type of transport.
bind_addr Indicates address to which the file descriptor is to be bound. The value can be a valid address or NULL.
sendsize Specify the send buffer size. If the value is set to 0, the default size for is used.
recvsize Specify the receive buffer size. If the value is set to 0, the default size is used.

Return Values

Item Description
a service handle successful
NULL unsuccessful

Examples

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

main()
{
      SVCXPRT *svc_handle;       /* server handle */
      struct netconfig *nconf;
  
      /* get proper file descriptor */       

      /* get transport type */
      nconf = getnetconfigent("tcp");
      if (nconf == (struct netconfig *) NULL)
      {
            fprintf(stderr, "getnetconfigent failed\n");
            exit(EXIT_FAILURE);
      }
  
      /* sendsize and recvsize are 0, thus default size will be chosen */
      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 */
      svc_run();                         
      return 0;
}