SocketTools .NET Edition

Network Time Protocol

The Time protocol control enables an application to retrieve the current time from a remote system, and optionally synchronize the local system time using that value. The first step that your application must take is to initialize the control. After the control has been initialized, the application can request the current time from a system and update the local system clock if necessary.

Overview

Initialize
Initialize an instance of the class, loading the networking library and validating the development license. This method must be called before any properties are changed or any other methods in this class are called by the application.

GetTime
Return the current time from a remote host. The time and date retrieved from the server will be returned as a string formatted according to the user's current locale. If the date could not be retrieved, an empty string will be returned.

SetTime
Update the local system time with the value returned by GetTime. This method requires that the current user have the appropriate permissions to modify the system time or the method will fail.

Reset
Reset the internal state of the component. This can be useful if your application wishes to discard any settings made by a user and return that instance of the class to its default state.

Uninitialize
Unload the networking library and release any resources that have been allocated for the current process. This is the last method call that the application should make prior to terminating. This is only necessary if the application has previously called the Initialize method.

Time Conversion

The class also provides a method which can be used to convert between the local date and time and UTC date and time for the value returned by the remote host.

ConvertTime
This method enables the application to easily convert between the network time value (which is expressed as a long integer specifying the number of seconds elapsed since midnight, January 1, 1900) and the System.DateTime class.