Getting time from Time Server

Does anyone know the programmatic syntax required to obtain the time from a time server such as

time-A.timefreq.bldrdoc.gov, or any other, for that matter?
Thank you.

Regards,
    Tony
sosdevAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mcriderCommented:
You can use the winsock control to connect to time-A.timefreq.bldrdoc.gov on port 13.  This will give you the time from that system.

To see what comes back, from the server, try this:

   telnet time-A.timefreq.bldrdoc.gov 13

Telnet will connect to the server on port 13 and receive the time and then terminate.

You can also check out http://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=10245806 


Cheers!
0
sosdevAuthor Commented:
Sorry mcrider. Looks like I blew 20 points on that one :)
I need a pure VB solution, not Telnet.

Thanks anyway.

Regards,
   Tony
0
mcriderCommented:
Like I said, you can use the WINSOCK CONTROL to connect to the server and get the data... 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...


Cheers!
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sosdevAuthor Commented:
:) Ah ... you're a nice guy for sticking with me.
Many thanks.

Regards,
    Tony
0
mcriderCommented:
You're welcome! Thanks for the points... Glad I could help!

Cheers!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming Languages-Other

From novice to tech pro — start learning today.