Click here to Skip to main content
15,884,537 members
Articles / Desktop Programming / Windows Forms

An SNTP Client for C# and VB.NET

Rate me:
Please Sign up or sign in to vote.
4.93/5 (29 votes)
22 Jul 2009CPOL11 min read 162.5K   9K   66  
A complete overview and implementation of SNTP from a client perspective.
Imports System

Namespace SNTP

    ''' <summary>
    ''' Arguments that are passed along with the SNTPClient.QueryServerCompleted event.
    ''' </summary>
    Public Class QueryServerCompletedEventArgs
        Inherits EventArgs

        Private _data As SNTPData
        Private _errorData As ErrorData
        Private _localDateTimeUpdated As Boolean
        Private _succeeded As Boolean

#Region "Constructors"

        Friend Sub New()
            _errorData = New ErrorData()
        End Sub

#End Region

#Region "Properties"

        ''' <summary>
        ''' Gets the data that was returned by the server.
        ''' </summary>
        ''' <returns>The data that was returned by the server.</returns>
        Public Property Data() As SNTPData
            Get
                Return _data
            End Get
            Friend Set(ByVal value As SNTPData)
                _data = value
            End Set
        End Property

        ''' <summary>
        ''' Gets data relating to any error that occurred.
        ''' </summary>
        ''' <returns>Data relating to any error that occurred.</returns>
        Public Property ErrorData() As ErrorData
            Get
                Return _errorData
            End Get
            Friend Set(ByVal value As ErrorData)
                _errorData = value
            End Set
        End Property

        ''' <summary>
        ''' Gets whether the local date and time was updated.
        ''' </summary>
        ''' <returns>Whether the local date and time was updated.</returns>
        Public Property LocalDateTimeUpdated() As Boolean
            Get
                Return _localDateTimeUpdated
            End Get
            Friend Set(ByVal value As Boolean)
                _localDateTimeUpdated = value
            End Set
        End Property

        ''' <summary>
        ''' Gets whether the server query completed successfully.
        ''' NB: It is possible that other errors occurred (not related to the querying of the server) after the query,
        ''' so ErrorData should still be examined regardless of the value of this property.
        ''' </summary>
        ''' <returns>Whether the server query completed successfully.</returns>
        Public Property Succeeded() As Boolean
            Get
                Return _succeeded
            End Get
            Friend Set(ByVal value As Boolean)
                _succeeded = value
            End Set
        End Property

#End Region

    End Class

End Namespace

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
CEO Dave Meadowcroft
United Kingdom United Kingdom
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions