Manual Pages for Linux CentOS command on man rtime
MyWebUniversity

Manual Pages for Linux CentOS command on man rtime

RTIME(3) Linux Programmer's Manual RTIME(3)

NAME

rtime - get time from a remote machine SYNOPSIS

#include int rtime(struct sockaddrin *addrp, struct rpctimeval *timep, struct rpctimeval *timeout); DESCRIPTION This function uses the Time Server Protocol as described in RFC 868 to obtain the time from a remote machine. The Time Server Protocol gives the time in seconds since 00:00:00 UTC, 1 Jan 1900, and this function subtracts the appropriate constant in

order to convert the result to seconds since the Epoch, 1970-01-01 00:00:00 +0000 (UTC).

When timeout is non-NULL, the udp/time socket (port 37) is used. Oth‐ erwise, the tcp/time socket (port 37) is used. RETURN VALUE

On success, 0 is returned, and the obtained 32-bit time value is stored

in timep->tvsec. In case of error -1 is returned, and errno is set appropriately. ERRORS All errors for underlying functions (sendto(2), poll(2), recvfrom(2), connect(2), read(2)) can occur. Moreover: EIO The number of returned bytes is not 4. ETIMEDOUT The waiting time as defined in timeout has expired. NOTES Only IPv4 is supported. Some in.timed versions support only TCP. Try the example program with usetcp set to 1. Libc5 uses the prototype int rtime(struct sockaddrin *, struct timeval *, struct timeval *); and requires instead of . BUGS

rtime() in glibc 2.2.5 and earlier does not work properly on 64-bit machines. EXAMPLE This example requires that port 37 is up and open. You may check that the time entry within /etc/inetd.conf is not commented out. The program connects to a computer called "linux". Using "localhost" does not work. The result is the localtime of the computer "linux".

#include

#include

#include

#include

#include

#include

#include int usetcp = 0; char *servername = "linux"; int main(void) { struct sockaddrin name; struct rpctimeval time1 = {0,0}; struct rpctimeval timeout = {1,0}; struct hostent *hent; int ret; memset(&name, 0, sizeof(name)); sethostent(1); hent = gethostbyname(servername);

memcpy(&name.sinaddr, hent->haddr, hent->hlength); ret = rtime(&name, &time1, usetcp ? NULL : &timeout); if (ret < 0) perror("rtime error"); else { timet t = time1.tvsec;

printf("%s\n", ctime(&t)); } exit(EXITSUCCESS); } SEE ALSO ntpdate(1), inetd(8) COLOPHON

This page is part of release 3.53 of the Linux man-pages project. A description of the project, and information about reporting bugs, can

be found at http://www.kernel.org/doc/man-pages/.

GNU 2012-08-03 RTIME(3)




Contact us      |      About us      |      Term of use      |       Copyright © 2000-2019 MyWebUniversity.com ™