Solved

Internet time protocol

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

Suggested Solutions

Title # Comments Views Activity
allswap challenge 6 152
How to make an ADE file by code? 11 111
How to hault or freeze parent form when a 2d form is open in vb6 3 48
pop out of webbrowser1 control vba6 5 52
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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.

751 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