clnt_geterr Macro

Important: The macro is exported from both the libc and the libnsl libraries.

clnt_geterr Macro Exported from the libc Library

Purpose

Copies error information from a client handle.

Library

C Library (libc.a)

Syntax

#include <rpc/rpc.h>

void clnt_geterr ( clnt,  errp)
CLIENT *clnt;
struct rpc_err *errp;

Description

The clnt_geterr macro copies error information from a client handle to an error structure.

Parameters

Item Description
clnt Points to the structure of the client handle.
errp Specifies the address of the error structure.

clnt_geterr Macro Exported from the libnsl Library

Purpose

Copies error information from a client handle.

Library

Network Services Library (libnsl.a)

Syntax

#include <rpc/rpc.h>
void clnt_geterr ( clnt, errp)
CLIENT *clnt;
struct rpc_err *errp;

Description

The clnt_geterr macro copies error information from a client handle to an error structure.

Parameters

Item Description
clnt Points to the structure of the client handle.
errp Specifies the address of the error structure.

Examples

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

int main()
{
  rpcprog_t PROGNUM = 0x3fffffffL;
  rpcvers_t PROGVER = 0x1L;
  rpcproc_t procnum = 0x1L;
  CLIENT *clnt;
  enum clnt_stat cs;
  struct rpc_err client_error;
  char hostname[255] ; /* The Remote Host */
  char *nettype = "tcp";
  struct timeval total_timeout = {25,0};
  
  int input_arguments , output_results  ;  

  if ((clnt=clnt_create(hostname, PROGNUM, PROGVER, nettype))==NULL)
  {
    fprintf(stderr,"clnt_create() subroutine failed");
    exit(1);
  }

  cs = clnt_call(clnt, procnum, (xdrproc_t)xdr_int,
           (char *)&input_arguments, (xdrproc_t)xdr_int,
           (char *)&output_results, total_timeout);

  if (cs != RPC_SUCCESS)
      clnt_geterr(clnt,&client_error);

  /* Destroy client handle in the end */
  clnt_destroy(clnt);

  return 0;
}