VxWorks Reference Manual : Libraries

sntpcLib

NAME

sntpcLib - Simple Network Time Protocol (SNTP) client library

ROUTINES

sntpcTimeGet( ) - retrieve the current time from a remote source

DESCRIPTION

This library implements the client side of the Simple Network Time Protocol (SNTP), a protocol that allows a system to maintain the accuracy of its internal clock based on time values reported by one or more remote sources. The library is included in the VxWorks image if INCLUDE_SNTPC is defined at the time the image is built.

USER INTERFACE

The sntpcTimeGet( ) routine retrieves the time reported by a remote source and converts that value for POSIX-compliant clocks. The routine will either send a request and extract the time from the reply, or it will wait until a message is received from an SNTP/NTP server executing in broadcast mode.

INCLUDE FILES

sntpcLib.h

SEE ALSO

sntpcLib, clockLib, RFC 1769


Libraries : Routines

sntpcTimeGet( )

NAME

sntpcTimeGet( ) - retrieve the current time from a remote source

SYNOPSIS

STATUS sntpcTimeGet
    (
    char *            pServerAddr, /* server IP address or hostname */
    u_int             timeout,     /* timeout interval in ticks */
    struct timespec * pCurrTime    /* storage for retrieved time value */
    )

DESCRIPTION

This routine stores the current time as reported by an SNTP/NTP server in the location indicated by pCurrTime. The reported time is first converted to the elapsed time since January 1, 1970, 00:00, GMT, which is the base value used by UNIX systems. If pServerAddr is NULL, the routine listens for messages sent by an SNTP/NTP server in broadcast mode. Otherwise, this routine sends a request to the specified SNTP/NTP server and extracts the reported time from the reply. In either case, an error is returned if no message is received within the interval specified by timeout. Typically, SNTP/NTP servers operating in broadcast mode send update messages every 64 to 1024 seconds. An infinite timeout value is specified by WAIT_FOREVER.

RETURNS

OK, or ERROR if unsuccessful.

ERRNO

 S_sntpcLib_INVALID_PARAMETER
 S_sntpcLib_INVALID_ADDRESS

SEE ALSO

sntpcLib