Solved

Internet time protocol

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

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 will show, step by step, how to integrate R code into a R Sweave document
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

707 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now