rtime(3) Library Functions Manual rtime(3) rtime - LIBRARY Standard C library (libc, -lc) #include int rtime(struct sockaddr_in *addrp, struct rpc_timeval *timep, struct rpc_timeval *timeout); Time Server Protocol, RFC 868. Time Server Protocol 1 1900 00:00:00 UTC. , -- 1970-01-01 00:00:00 +0000 (UTC). timeout NULL, udp/time ( 37), -- tcp/time ( 37). On success, 0 is returned, and the obtained 32-bit time value is stored in timep->tv_sec. In case of error -1 is returned, and errno is set to indicate the error. (sendto(2), poll(2), recvfrom(2), connect(2), read(2)), : EIO 4. ETIMEDOUT , , . attributes(7). +----------------------------+----------------------------------------------------------+--------------------------+ | | | | +----------------------------+----------------------------------------------------------+--------------------------+ |rtime() | | MT-Safe | +----------------------------+----------------------------------------------------------+--------------------------+ IPv4. in.timed TCP. 1 use_tcp. rtime() glibc 2.2.5 64- . 37. , , /etc/inetd.conf time . <>. <> . <>. #include #include #include #include #include #include #include static int use_tcp = 0; static const char servername[] = "linux"; int main(void) { int ret; time_t t; struct hostent *hent; struct rpc_timeval time1 = {0, 0}; struct rpc_timeval timeout = {1, 0}; struct sockaddr_in name; memset(&name, 0, sizeof(name)); sethostent(1); hent = gethostbyname(servername); memcpy(&name.sin_addr, hent->h_addr, hent->h_length); ret = rtime(&name, &time1, use_tcp ? NULL : &timeout); if (ret < 0) perror("rtime error"); else { t = time1.tv_sec; printf("%s\n", ctime(&t)); } exit(EXIT_SUCCESS); } . ntpdate(1), inetd(8) aereiae , Azamat Hackimov , Dmitriy S. Seregin , Katrin Kutepova , Lockal , Yuri Kozlov , ; GNU 3 , . . , , . Linux man-pages 6.06 31 2023 . rtime(3)