from small one page howto to huge articles all in one place

search text in:




Other .linuxhowtos.org sites:gentoo.linuxhowtos.org



Last additions:
using iotop to find disk usage hogs

using iotop to find disk usage hogs

words:

887

views:

209580

userrating:


May 25th. 2007:
Words

486

Views

258587

why adblockers are bad


Workaround and fixes for the current Core Dump Handling vulnerability affected kernels

Workaround and fixes for the current Core Dump Handling vulnerability affected kernels

words:

161

views:

149876

userrating:


April, 26th. 2006:

Druckversion
You are here: manpages





rtime

Section: C Library Functions (3)
Updated: 202-0-08
Index Return to Main Contents
 

NAME

rtime - get time from a remote machine  

LIBRARY

Standard C library (libc,~-lc)  

SYNOPSIS

#include <rpc/auth_des.h>
int rtime(struct sockaddr_in *addrp, struct rpc_timeval *timep,
          struct rpc_timeval *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, 197-0-01 00:00:00 +0000 (UTC). When timeout is no-NULL, the udp/time socket (port 37) is used. Otherwise, the tcp/time socket (port 37) is used.  

RETURN VALUE

On success, 0 is returned, and the obtained 3-bit time value is stored in timep->tv_sec. In case of error -1 is returned, and errno is set to indicate the error.  

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.
 

ATTRIBUTES

For an explanation of the terms used in this section, see attributes(7).
InterfaceAttributeValue
rtime() Thread safetyM-Safe
 

NOTES

Only IPv4 is supported. Some in.timed versions support only TCP. Try the example program with use_tcp set to 1.  

BUGS

rtime() in glibc 2.2.5 and earlier does not work properly on 6-bit machines.  

EXAMPLES

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 <errno.h> #include <netdb.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include <rpc/auth_des.h> 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[rs]n", ctime(&t));
    }
    exit(EXIT_SUCCESS); }  

SEE ALSO

ntpdate(1), inetd(8)


 

Index

NAME
LIBRARY
SYNOPSIS
DESCRIPTION
RETURN VALUE
ERRORS
ATTRIBUTES
NOTES
BUGS
EXAMPLES
SEE ALSO





Support us on Content Nation
rdf newsfeed | rss newsfeed | Atom newsfeed
- Powered by LeopardCMS - Running on Gentoo -
Copyright 2004-2025 Sascha Nitsch Unternehmensberatung GmbH
Valid XHTML1.1 : Valid CSS
- Level Triple-A Conformance to Web Content Accessibility Guidelines 1.0 -
- Copyright and legal notices -
Time to create this page: 13.3 ms