Solved

Internet time protocol

Posted on 2000-02-29
4
189 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

This article will show, step by step, how to integrate R code into a R Sweave document
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This video teaches viewers about errors in exception handling.

636 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