Results 1 to 4 of 4

Thread: Connecting to NTP Server (VB6 Winsock)

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2006
    Posts
    16

    Connecting to NTP Server (VB6 Winsock)

    I'm having a hard time figuring this one out. It could be that I don't know much about UDP, though I did manage to write a simple chat program a while ago.
    The only information I've been able to find is that the NTP server uses UDP Port 123. What I can't seem to find is how to actually get the information from the server (I'll worry about decoding it later).

    I was able to easily use the old TIME servers, connecting on TCP port 37, and automatically getting the data back, but not having so much luck here.
    I did try sending some random data ("Test" or something), hoping that would trigger some data to come back at me, but no luck.

    :s
    Thanks for reading and hopefully helping

  2. #2
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: Connecting to NTP Server (VB6 Winsock)

    As you can see at http://en.wikipedia.org/wiki/Network_Time_Protocol NTP is not something you can implement as a simple client based on request/response transactions. Clients are normally implemented as a service, often a kernel service because if you need time precision at this level your code has to run with very high priority.

    The actual mechanism is explained in a number of RFCs (see links at the page I linked to above). It is a complicated process because it attempts to discover and correct for network delays which are variable over time.

    You might look at SNTP as a starting point if you truly want to play with this.


    Edit:

    No, there is no "connecting" since NTP is a UDP protocol.

    See SNTPClient UserControl for a working solution.
    Last edited by dilettante; Dec 28th, 2013 at 12:11 AM. Reason: updated for anyone who stumbles in here in the future

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jun 2006
    Posts
    16

    Re: Connecting to NTP Server (VB6 Winsock)

    Thank you for the information. Doesn't there have to be some quick way of receiving the time information though? I found a program that will connect on demand to an NTP time server of my choice to update the system clock. Wouldn't this mean that a specific message must be sent somehow to the server to request the information back?
    I know that the process to do this properly wouldn't be so simple, but I'm just looking for some sort of information back as a test. I've looked at all of these websites, but I haven't been able to find anything concrete as to actually how it is done, connectionwise.

  4. #4
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: Connecting to NTP Server (VB6 Winsock)

    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width