Solved

Internet time protocol

Posted on 2000-02-29
4
182 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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

If you haven’t already, I encourage you to read the first article (http://www.experts-exchange.com/articles/18680/An-Introduction-to-R-Programming-and-R-Studio.html) in my series to gain a basic foundation of R and R Studio.  You will also find the …
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

832 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