Returns the time on a remote host.
Network Services Library (libnsl.a)
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.
Item | Description |
---|---|
host | Specifies the host name on which the server resides. |
time_p | Specifies the time on the host. |
Item | Description |
---|---|
TRUE | successful |
FALSE | unsuccessful |
#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;
}