Getting the Internet Time, Page 2
Believe it or not, there was a time when the Net didn't exist. Back then, technical boffins sat around dreaming up the likes of HTTP and FTP 'protocols', acronyms currently running the real core of the Internet.
It was back in those golden days when a special little baby called NTP was born.
NTP stands for Network Time Protocol and is a method of retrieving the date and time from other computers. It was originally conjured up to allow supercool networked computers to synchronise the current time amongst one another.
And this protocol still exists. A large number of huge Internet computers all of which maintain incredibly accurate 'atomic' times allow you to simply connect to them, grab the date and time, then say goodbye.
It's supposed to be simple. In fact, it is simple. But few programmers actually know about it.
Let's perform a little experiment with the Network Time Protocol:
- Click 'Start', 'Run'
- Type in 'Telnet' then click 'OK'
- Select 'Connect', 'Remote System'
This Telnet program allows you to connect to other computers. In the host name, we need to type in the computer that will allow us to access the NTP information.
- Under 'Host Name', type in: "pogostick.net"
Top Tip: Lists of public NTP computers or 'servers' can be found all over the Internet. Others include tick.usno.navy.mil, ntp0.strath.ac.uk, ntp.univ-lyon1.fr, chime1.surfnet.nl and bernina.ethz.ch
And now for the important bit. The 'Port' is like the channel on your television. You need to tune into the right channel to get the right information. And it's the same here - for the NTP service, you need to tune into port 13. Let's do that now:
- Under 'Port', type in: "13"
- Ensure you're connected to the Internet, then click 'Connect'
Now you should be presented with a little message box saying the connection is closed or some such. Let me explain what's happened here.
When you connected, Telnet found the pogostick.net computer and connected to port 13. The pogostick.net computer knows what to do on port 13 it instantly throws back the current date and time, which you should be able to see in the white Telnet window. As soon as that has occurred, it disconnects and Telnet displays the message box on your screen right now.
Top Tip: A lot of people think Internet traffic might alter the accuracy of the time coming back. But in reality, it rarely takes more than a half-second for the information to arrive back at your computer and most time servers make an allowance for this.
So, we know it is possible to retrieve the current date and time from accurate, beast-like computers. But how can you do it in Visual Basic?
Page 2 of 6