rpcb_gettime Subroutine

Purpose

Returns the time on a remote host.

Library

Network Services Library (libnsl.a)

Syntax

#include <rpc/rpc.h>
bool_t rpcb_gettime(host, time_p)
const char *host;
time_t *time_p;

Description

You can obtain the time on a remote host using the rpcb_gettime subroutine. The time is returned by the time_p parameter. You must preallocate the time_p parameter before calling this subroutine. If the host is specified with a null value, this subroutine returns the time on the local machine from which the subroutine is called. Generally, the rpcb_gettime subroutine is used to synchronize the time between clients and servers. This subroutine is particularly needed for secure remote procedure call (RPC) applications in which clients and servers must be synchronized.

Parameters

Item Description
host Specifies the host name on which the server resides.
time_p Specifies the time on the host.

Return Values

Item Description
TRUE successful
FALSE unsuccessful

Examples

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

int main()
{
    char hostname[255] ; /* The Remote host */
    time_t        time_p = 0;

    if( rpcb_gettime(hostname, &time_p)== FALSE ) {
          fprintf(stderr,"rpcb_gettime failed");
          exit(1);          
     }
     return 0;
}