Reading Computer's clock over a network

How can I read other computer's clock over a network using VB code.

Are there any programs out there (VB or other) which will do this. I don't care about synchronizign the clocks on computers over a network but I want to know how to read other computer's clock over a network.

Thank you.
aussie_guy_nikAsked:
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.

aussie_guy_nikAuthor Commented:
No comment
0
mcriderCommented:
If you have a system that runs the DAYTIME protocol, you can use the winsock control to connect to that system on port 13.  Most UNIX systems run this service.

Once you connect, the system will send the time, then disconnect.  The format usually is one of the following:

     Sunday, December 12, 1999 23:59:10-EST
     SUN DEC 12 23:59:10 1999
     12 FEB 99 23:59:10 EST

See the following Microsoft Article:

HOWTO: Use NT Simple TCP/IP Services for Winsock Testing
http://support.microsoft.com/support/kb/articles/Q177/6/99.ASP 
 

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
aussie_guy_nikAuthor Commented:
I have tried running the code in the article but it didn't work.
The exe was running but it kept on giving an error "Forcefully disconnected".

I am running windows98 on both machines and not windows NT. Could this be a problem perhaps?

Also when it asks for the server name I type in the other machines name, I hope that's what it means by server name.

What am I doing wrong?
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

mcriderCommented:
The server name is the DNS name or IP address of the system running the DAYTIME protocol TIMESERVER.

You followed the directions exactly and you are clicking the TIME button in the example right? I used the example on a WIN95/WIN98 system and it worked perfectly...

Most likely what is happening is the host you are connecting to does not have a TIMESERVER running on port 13.

There is a quick way to check this...

Open a DOS box and type in at the prompt:


   telnet <servername> 13

where <servername> is the name of the server running the TIMESERVER.

If you get a telnet box that pops open and shows the time and then immediately closes the connection, the server is running the TIMESERVER... If not, you will need to start a TIMESERVER...


Let me know how it turns out....
0
mcriderCommented:
By the way, here is the code for a TIMESERVER in VB.

Create a new project.

Add a winsock control to the project.

Set the index of the winsock control to 0.

paste the following code into the DECLARATIONS SECTION of the form and run the program... Anyone can then connect to your system on port 13 and they will receive your system clocks time...


Cheers!


THE CODE:

Private Sub Form_Load()
    Winsock1(0).LocalPort = 13
    Winsock1(0).Listen
End Sub
Private Sub Winsock1_ConnectionRequest(Index As Integer, ByVal requestID As Long)
    Dim iVal As Integer
    iVal = Winsock1.Count
    Load Winsock1(iVal)
    Winsock1(iVal).Accept requestID
    Winsock1(iVal).SendData CStr(UCase(Format(Now, "DDD MMM dd hh:nn:ss yyyy")))
    DoEvents
    Winsock1(iVal).Close
    DoEvents
    Unload Winsock1(iVal)
End Sub
0
mcriderCommented:
you can quickly test the above VB TIMESERVER by using the following telnet command:


     telnet localhost 13


Cheers!
0
LCPCommented:
If you don't mind using dos prompt at your application, you can use:

NET TIME \\COMPUTERNAME

to get the server time.

Samuel
0
aussie_guy_nikAuthor Commented:
mcrider you are a legend!!!!!

it worked beautifully. Thank you.

Samuel you are a legend too. If you were quicker i would have given you the points.

This site is the best thing since slice bread as Luke would say.

Thanks guys.

Mezzenga
0
mcriderCommented:
Thanks for the points! Glad I could help!

By the way, NET TIME \\COMPUTERNAME does not use the DAYTIME protocol and only works against Window For Workgroups,WIN95, WIN98, NT and Novell Time Servers...


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.