Method | Description | |
---|---|---|
BeginRequestTime ( ) : void |
Asynchronously requests a time from the NTP server specified in the constructor. When a time is received the TimeReceived event is raised with the result, otherwise the ErrorOccurred event should be raised containing details of the failure. Note, events raised by this class may not (and probably will not) occur on the same thread that called this method. If the event handlers call UI components, dispatched invoke may be required. This method may throw exceptions (most likely a NtpNetworkException if an error occurs trying to connect/bind to the network endpoint. Exception handling in client code is recommended. |
|
NtpClient ( ) : System |
Default constructor. Uses the KnownNtpServers.TimeANist server as a default.
|
|
NtpClient ( string serverAddress ) : System |
Full constructor.
|
|
RequestTimeAsync ( ) : System.Threading.Tasks.Task |
Returns an awaitable task whose result is the current time from the NTP server specified in the constructor. This method may throw exceptions (most likely a NtpNetworkException if an error occurs trying to connect/bind to the network endpoint. Exception handling in client code is recommended. |
Method | Description | |
---|---|---|
OnErrorOccurred ( |
Raises the ErrorOccurred event. This event may be raised on a different thread than called the BeginRequestTime method. If the event handler refers to UI, COM or other components that require thread affinity then dispatched invoke may be required. |
|
OnTimeReceived ( System.DateTime time ) : void |
Raises the TimeReceived event. This event may be raised on a different thread than called the BeginRequestTime method. If the event handler refers to UI, COM or other components that require thread affinity then dispatched invoke may be required. The time returned is a UTC time. |
Method | Description | |
---|---|---|
ConvertBufferToCurrentTime ( byte buffer ) : void | ||
ExceptionToNtpNetworkException ( |
||
ExecuteWithSuppressedExceptions ( System.Action work ) : void | ||
NtpNetworkExceptionFromSocketArgs ( SocketAsyncEventArgs e ) : |
||
OnErrorOccurredAndDisposeSocket ( |
||
SendTimeRequest ( ) : void | ||
Socket_Completed_ProcessResult ( object sender, SocketAsyncEventArgs e ) : void | ||
Socket_Completed_Receive ( Windows sender, Windows args ) : void | ||
Socket_Completed_Receive ( object sender, SocketAsyncEventArgs e ) : void | ||
Socket_Completed_SendAgain ( object sender, SocketAsyncEventArgs e ) : void | ||
sArgs_Completed ( object sender, SocketAsyncEventArgs e ) : void |
public NtpClient ( string serverAddress ) : System | ||
serverAddress | string | the name or address the NTP server to be used. |
return | System |
protected OnErrorOccurred ( |
||
exception | A |
|
return | void |
protected OnTimeReceived ( System.DateTime time ) : void | ||
time | System.DateTime | The date and time received from the NTP server. |
return | void |
public RequestTimeAsync ( ) : System.Threading.Tasks.Task |
||
return | System.Threading.Tasks.Task |