Solved

Internet time protocol

Posted on 2000-02-29
4
183 Views
Last Modified: 2013-11-13
I need to write a program that use the Internet time protocol in order to get the time from a remote server. I'd like to connect to a remote host and get the time in seconds since 1/1/1900, and then to change it in a local time using MS Winsock.
0
Comment
Question by:gcriaco
  • 2
4 Comments
 
LVL 8

Expert Comment

by:stefanx
ID: 2570411
You can get the inner working of the Network Time Protocol from RFC1305. You can download this from ftp://ftp.is.co.za/internet/in-notes/rfc/rfc1305.pdf.

0
 

Author Comment

by:gcriaco
ID: 2572236
Edited text of question.
0
 

Author Comment

by:gcriaco
ID: 2572291
Thanks for info. BTW, i already knew this doc. I need a vb code example that connect a pc to a time server (i.e.  time-nw.nist.gov (Microsoft)) on port 13 and gets a number of seconds since 1/1/1900.
Then i figure out to use the vb dateadd function to synchronyze the local clock.
0
 
LVL 28

Accepted Solution

by:
AzraSound earned 200 total points
ID: 2643288
This uses a winsock control but it works
Here's a complete example:

1) In a new project, add a command button to Form1.

2) Add a winsock control to the form.  You can do this by right-clicking the toolbox and selecting "Components..." then select "Microsoft Winsock Control" from the list.

3) Add the following code to the DECLARATIONS SECTION of the form:

    Private Sub Command1_Click()
        Dim RemoteTime As String
        Dim tString As String
        Winsock1.Tag = "" 
        Winsock1.RemoteHost = "time-A.timefreq.bldrdoc.gov"
        Winsock1.RemotePort = 13
        Winsock1.Connect
        DoEvents
        Do While Not Winsock1.State = sckClosed
            DoEvents
        Loop
        MsgBox Winsock1.Tag
    End Sub
    Private Sub Winsock1_Close()
        Winsock1.Close
    End Sub
    Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
        Dim lBuf As String
        Winsock1.GetData lBuf, vbString
        Winsock1.Tag = Winsock1.Tag + lBuf
        DoEvents
    End Sub


4) Run the program and click the button... A message box will appear with the timer from the server...

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
The viewer will learn how to implement Singleton Design Pattern in Java.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question