clnt_destroy Macro

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

clnt_destroy Macro Exported from the libc Library

Purpose

Destroys the client's Remote Procedure Call (RPC) handle.

Library

C Library (libc.a)

Syntax

#include <rpc/rpc.h>

void clnt_destroy ( clnt)
CLIENT *clnt;

Description

The clnt_destroy macro destroys the client's RPC handle. Destroying the client's RPC handle deallocates private data structures, including the clnt parameter itself. The use of the clnt parameter becomes undefined upon calling the clnt_destroy macro.

Parameters

Item Description
clnt Points to the structure of the client handle.

clnt_destroy Macro Subroutine Exported from the libnsl Library

Purpose

Destroys the handle of a remote procedure call (RPC) client.

Library

Network Services Library (libnsl.a)

Syntax

#include <rpc/rpc.h>
void clnt_destroy(clnt)
CLIENT *clnt;

Description

The clnt_destroy macro subroutine is a top-level API for transport-independent remote procedure calls (TI_PRC). The macro subroutine destroys the handle of the RPC client that is obtained after a successful call to any of the client-creation subroutines. The clnt parameter is deallocated along with other private data structures. After a call to this macro subroutine, the use of the clnt parameter is undefined. Any associated file descriptor will be closed if the RPC library has opened the associated file descriptor or was set using the clnt_control subroutine.

Parameters

Item Description
clnt Points to the structure of the client handle.

Return Values

The clnt_destroy macro subroutine fails if the specified client handle has a null value.

Examples

In the following example, the clnt_destroy macro subroutine successfully destroys the client handle that is returned by the clnt_create subroutine.

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

int main()
{
    CLIENT *cl;
    rpcprog_t PROGNUM =      x3fffffffL ;
    rpcvers_t PROGVER =      x1L ;
    char *nettype = "visible";
    char hostname[255];      /* The name of remote host */

      /*
    * make the clnt_create call with this nettype and
    * observe the result
    */
    if ((cl=clnt_create( hostname, PROGNUM, PROGVER, nettype)) == NULL)
    {
         fprintf(stdout, "clnt_create : failed.\n");
         exit(EXIT_FAILURE);
    }
    /* 
     * Make a call to clnt_call() subroutine 
     */
    /* Destroy the client handle when no more needed */
     clnt_destroy( cl );

    return 0;    
}