svc_getrpccaller Subroutine

Purpose

Gives the network address of a caller of a procedure (a server-side subroutine).

Library

Network Services Library (libnsl.a)

Syntax

#include <rpc/rpc.h>
struct netbuf *svc_getrpccaller( xprt );
SVCXPRT *xprt;

Description

The svc_getrpccaller subroutine gives network address of a caller of a procedure associated with the remote procedure call (RPC) service handle.

Parameters

Item Description
xprt Represents the RPC service handle.

Return Values

On successful completion, the svc_getrpccaller subroutine returns network address of a caller.

Examples

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

#define PROG 0x3fffffffL
#define VERS 0x1L

static void sample_dispatch();
main()
{
    char *nettype;
    int no_of_handles;
            
    nettype = "tcp";

    /* Create RPC service handle and register with RPCBIND service */
    if((no_of_handles = svc_create(sample_dispatch, PROG, VERS,nettype)) == 0)
    {
        fprintf(stdout,"Error in svc_create!");
        exit(EXIT_FAILURE);
    }
    svc_run();
    return 0;
} 

/* following is the sample dispatch routine*/
static void sample_dispatch(struct svc_req *request, SVCXPRT *xprt)
{
    int result;
    struct netbuf *clntaddr;
    
    /* Get client's name and address */
    clntaddr = svc_getrpccaller(xprt);

    /* send reply back to client */ 
}