rpcb_rmtcall Subroutine

Purpose

Instructs the rpcbind service on a remote host to make a remote procedure call (RPC) on behalf of the caller to a procedure on that host.

Library

Network Services Library (libnsl.a)

Syntax

#include <rpc/rpc.h>
enum clnt_stat rpcb_rmtcall(nconf, host, prognum, progver, procnum, in_proc, input, out_proc, output,
 t_out, svcaddr)
const struct netconfig *nconf
const char *host
const rpcprog_t prognum;
const rpcvers_t versnum;
const rpcproc_t procnum;
const xdrproc_t in_proc;
const caddr_t input;
const xdrproc_t out_proc;
const caddr_t output;
const struct timeval t_out;
struct netbuf *svcaddr

Description

The rpcb_rmtcall subroutine is an interface to the rpcbind service. The subroutine instructs the rpcbind service on the remote host to make an RPC call on behalf of the caller to a procedure on that host. The netconfig structure must correspond to a connectionless transport. You can use this subroutine for a ping program because the subroutine performs the lookup and call in one step.

Parameters

Item Description
host Specifies the host name on which the server resides.
prognum Specifies the program number of the remote host.
progver Specifies the version number of the remote host.
procnum Specifies the procedure number on the remote host.
in_proc Specifies the eXternal Data Representation (XDR) procedure to encode the input parameters.
out_proc Specifies the XDR procedure to decode the output results.
output Specifies the address of output parameters.
t_out Specifies the timeout value.
input Specifies the address of input parameters.
nconf Specifies the protocol associated with the service.
svcaddr Specifies the address of the remote service when the procedure succeeds.

Return Values

Item Description
RPC_SUCCESS successful
nonzero unsuccessful

Error Codes

Item Description
RPC_TIMEDOUT
  • The netconfig structure corresponds to a connection-oriented transport.
  • The version number is not valid.
  • The program number is not valid.
  • The procedure number is not valid.

Examples

#include <rpc/rpc.h>

int main()
{
    struct netconfig *nconf;
    rpcprog_t PROGNUM = 0x3fffffffL;
    rpcvers_t PROGVER = 0x1L;
    rpcproc_t PROCNUM = 0x1L;
    struct timeval timeout = {25,0};
    int req , resp;
    enum clnt_stat cs;
    char host[255]; /* Remote host name */

    req = 5 ; /* initialise input parameter to a valid value */

    /* Set the netconfig structure for tcp transport */
    if ((nconf = getnetconfigent("tcp")) ==(struct netconfig *) NULL) {
        printf("getnetconfigent() failed");
        exit(1);
    }

    /* Call the remote procedure using rpcb_rmtcall() */
    cs = rpcb_rmtcall(nconf,host,PROGNUM,PROGVER,PROCNUM,(xdrproc_t)xdr_int,
        (caddr_t)&req, (xdrproc_t)xdr_int, (caddr_t)&resp, timeout, nbuf);

    /* Check for the return status */
    if(cs != RPC_SUCCESS)
    {
        printf("rpcb_rmtcall() failed");
        exit(1);
    }

    return 0;
}