Indy 9
TIdSNTP
Hierarchy, Properties, Methods, Events, See Also, Unit: IdSNTP
Implements a Simple Network Time Protocol client.
TIdSNTP = class(TIdUDPClient)
Unit
IdSNTP
Description
The TIdSNTP implements a client for the Simple Network Time Protocol (SNTP), as described in the Internet standards document:

  • RFC 2030 - Simple Network Time Protocol (SNTP) Version 4 for IPv4, IPv6 and OSI (http://www.rfc-editor.org/rfc/rfc2030.txt)

SNTP is an extremely reliable protocol for time-synchronization on the Internet with accuracy from 1 to 50 milliseconds, even over great distances.

SNTP Version 4 includes certain optional extensions to the basic Version 3 model. TIdSNTP does not implement the optional extensions for either Key Identifier or Message Digest portions of the NTP/SNTP message format.

TIdSNTP, a descendant of TIdUDPClient, utilizes SNTP in the unicast client mode.


TIdSNTP.AdjustmentTime
TIdSNTP, See Also
Local clock offset
property AdjustmentTime: TDateTime;
Description
AdjustmentTime is a read-only TDateTime property that returns the local clock offset calculated when DateTime is retrieved from the SNTP server.

AdjustmentTime is calculated according to the algorithm in RFC 2030.


TIdSNTP.CheckStratum
TIdSNTP, See Also
Indicates the Stratum number is used when validating a server response.
property CheckStratum: Boolean;
Description
CheckStratum is a Boolean property that indicates if the Stratum value in the TNTPGram response should be used when determining the DateTime from the SNTP server. When CheckStratum is True, the numeric Stratum number in the response is validated before accepting the date time value from the server. The default value for CheckStratum is True, as assigned in the Create constructor.

TIdSNTP.DateTime
TIdSNTP, See Also
Date and time returned for the client
property DateTime: TDateTime;
Description
DateTime is a read-only TDateTime property used to store the date and time value retrieved using the SNTP client.

The value in DateTime is read using the protected function GetDateTime. GetDateTime creates an TNTPGram datagram , transmits the datagram as a string containing the unicast SNTP request using Send, and retrieves the response using ReceiveString. If the response is not an empty string, TIdSNTP properties are updated with values in the response.

The value in DateTime can be 0.0 when the NTP datagram response is either an empty string or ignored based on values in LeapIndicator, Stratum, or TransmitTimestamp fields of the response TNTPGram.

Reading the value of DateTime does not affect the clock on the local computer. Use SyncTime to read the value in DateTime prior to updating the clock on the local computer.


TIdSNTP.RoundTripDelay
TIdSNTP, See Also
Elapsed duration required to retrieve the date and time value.
property RoundTripDelay: TDateTime;
Description
RoundTripDelay is a read-only TDateTime property that returns the round trip delay duration calculated when DateTime is retrieved from the SNTP server.

RoundTripDelay is calculated according to the algorithm in RFC 2030.


TIdSNTP.Create
TIdSNTP, See Also
Constructor for the object instance.
constructor Create(AOwner: TComponent); override;
Parameters
AOwner: TComponent
Owner of the object instance.
Description
Create is the constructor for the object instance. Create calls the inherited Create method using AOwner as the owner of the object instance. Create sets the default value for the Port property to IdPORT_SNTP, as required in the SNTP protocol. Create also sets CheckStratum to True, indicating Stratum numbers are used in verifying NTPGram results from an SNTP server.

TIdSNTP.SyncTime
TIdSNTP, See Also
Updates the clock on the local computer.
function SyncTime: Boolean;
Return Value
Boolean - True on success.
Description
SyncTime is a Boolean function that updates the clock on the local computer, and returns True if the value of DateTime is not an invalid value and the TNTPGram response is not ignored.

Created with Doc-O-Matic 2 donated to Project JEDI. Commercial license available from the Doc-O-Matic site.