svc_fd_create Subroutine

Purpose

Creates a remote procedure call (RPC) service handle on an open and bound file descriptor.

Library

Network Services Library (libnsl.a)

Syntax

#include <rpc/rpc.h>
SVCXPRT *svc_fd_create(fd, sendsize, recvsize)
int fd;
const uint_t sendsize;
const uint_t recvsize;

Description

The svc_fd_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 a service handle over a given file descriptor. The file descriptor must be open and bound that is connected to a connection-oriented transport. This subroutine does not register a server with RPC services because the program number and version number are not specified. The size of the send and receive buffers can be specified by the sendsize and recvsize parameters. If the values of the sendsize and recvsize parameters are set to 0, the default size is used for buffers.

Parameters

Item Description
fd Indicates an open file descriptor that is bound.
sendsize Specify the send buffer size. If the value is set to 0, the default size for that transport is used.
recvsize Specify the receive buffer size. If the value is set to 0, the default size for that transport is used.

Return Values

Item Description
an PRC service handle successful
NULL unsuccessful

Examples

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

main()
{
        SVCXPRT *svc_handle;      /* server handle */
        int fd;                   /* file descriptor */  
        /* Get proper file descriptor */                     
  
        /* sendsize and recvsize are 0, thus default size will be chosen */
        
        if((svc_handle = svc_fd_create(fd, 0, 0))==(SVCXPRT *)NULL)
        {
                    fprintf(stdout,"Error in svc_fd_create!");
                    exit(EXIT_FAILURE);
        }
  
        /* Register RPC service */
              
        svc_run();
        return 0;
}