rpcb_set Subroutine

Purpose

Establishes a mapping between the program, version, netconfig structure and the service address.

Library

Network Services Library (libnsl.a)

Syntax

#include <rpc/rpc.h>
bool_t rpcb_set(prognum, progver, nconf, svcaddr)
const rpcprog_t prognum;
const rpcvers_t progver;
const struct netconfig *nconf;
struct netbuf *svcaddr

Description

The rpcb_set subroutine is used to establish a mapping of triplet (the program number, version number and the nc_netid field of the nconf argument) to the service on a remote host. The mapping is established on the rpcbind service of the machine. The svcaddr parameter specifies the address of the remote service. The nc_netid field of the netconfig structure identifies the network identifier defined by the netconfig database.
Note: This subroutine fails if it tries to create a mapping that exists on the machine.

Parameters

Item Description
prognum Specifies the program number of the remote program.
progver Specifies the version number of the remote program.
nconf Specifies the protocol associated with the service.
svcaddr Specifies the address of the remote service.

Return Values

Item Description
TRUE successful
FALSE unsuccessful

Error Codes

The rpcb_set subroutine returns failure if one or more of the following codes are true.

Item Description
RPC_UNKNOWNPROTO The value of the netconfig argument is not valid.
RPC_UNKNOWNADDR The remote service address is not valid.

Examples

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

int main()
{
    rpcprog_t PROGNUM ;
    rpcvers_t PROGVER ;
    struct netconfig *nconf ;
    struct netbuf *nbuf;
    struct t_bind *bind_addr = NULL;

    /* Get netconfig structure corresponding to tcp transport */ 
    if ((nconf = getnetconfigent("tcp")) == (struct netconfig *) NULL)
    {
        fprintf(stderr, "getnetconfigent failed");
        exit(1);
    }
    /* 
     * Code to open and bind file descriptor to bind_addr address 
     */
    nbuf = &bind_addr->addr;
    if( rpcb_set(PROGNUM, PROGVER, nconf, nbuf) == FALSE ) {
        fprintf(stderr,"rpcb_set() failed");
        exit(1);
    }
    svc_run();
    return 0;
}