The standard way of synchronization PC clock though
Internet is using special Network Time Protocol (NTP). It was
mainly developed at the Delaware University in the United States.
Tree versions of NTP were defined: the first on 1988, the second
on 1989, the third on 1992. The current version is the third that
is compatible with the previous ones. To make the use of NTP on
personal computers easier, on 1995 it was defined the Simplified
NTP (SNTP).
Unfortunately standard windows software of Win95/98/ME/NT/W2KPro
is not support synchronization PC Clock using Internet.
When I solved to create synchronization program I chose
HTTP (Hypertext Transfer Protocol) instead SNTP. I like it
because it is more universal. All WWW pages that you watch are
brought to the screen of your PC using this protocol. I created
the program and called it "For Atomic Synchronization".
There are a lot of government and scientific sites that
shows atomic time. There is small delay of site opening and
receiving information. I explore my program "For Atomic
Synchronization" during some month. Net delay seldom
overloads 2 seconds. I take half delay and correct time according
it. As result I cannot find difference between my PC clock time
and time that I watch on TV Screen ore hear in FM receiver.
As a time source I use site of Time Service Department
of U.S. Naval Observatory. It is official Source of Time for the
Department of Defense and the Standard of Time for the United
States. I have tested some others. They all works well but this
one have very simple format. The WWW page size is only 603
symbols (including html tags). Try this URL: http://tycho.usno.navy.mil/cgi-bin/timer.pl
and you will see same information as my program gets.

"For Atomic Synchronization" program is
big enough for describing. To demonstrate main principles of
synchronization I create small project that is described below.

Reading WWW sites using Win
API

Modern Windows versions with Internet Explorer 4.0
or later have very nice Internet API functions. You need not work
with such low terms as TCP/IP protocol, sockets, ports, DNS, http
protocol and etc. In this example I use API functions instead
same MFC classes because they are more universal and you can easy
translate this code to VB ore to other program language.
All API functions work as chains. The first function
opens Windows resource and returns its number that is named
"handle". Next function must use this handle. It could
return other handle, return code or something else. You mast
close handle when you need not it any more.

Look at the function CBSAtomicEduDlg::OnSyncro (see code
below). It works with Internet as user:
1) Function InternetOpen is opens Internet. If you are off line
now it opens Dialup connection window.
2) Function InternetOpenUrl retrieves the site that you are
looking for.
3) Function InternetReadFile reads the site into the text buffer.

It is all! You have the text of site! Do with it that you
want!

And do not forget check errors and close handles (function
InternetCloseHandle).
Such a way you can explore any information in Internet!

Do not forget to include in the project "Wininet.h"
file !

Universal and Local time

My watch show 02:00 am when there is midnight in
London. The sun is rolling around the Earth so there is different
time in different places. (P.s. I heard about Copernicus and
Jordano Bruno). To define what time we use in the place where we
are, we use special time zone. Time zones are not strips on a
globe. They were created not only according geographical
longitude but according states (countries) delimiters too. If you
want to synchronize your PC using Internet you must have right
zone information in your Operating System. You had set it while
was installing OS and can change any time later.
If you know Universal time (GMT) and your time zone you
can ease calculate your local time.
Look at function LocalZoneTime (see code bellow). It calculate
Universal time to Local time using time zone information.
Universal time I got from WWW site. All information about time
zone that I need I received by calling Win API function
GetTimeZoneInformation. Look at Microsoft help to understand how
use this information. The information includes DST (daylight
saving time) correction.

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. Afterdownloading it, you will need a program like Winzip to decompress it.Virus note:All files are scanned once-a-day by Planet Source Code for viruses, but new viruses come
out every day, so no prevention program can catch 100% of them. For your own safety, please:

Use this form to tell us if this entry should be deleted (i.e contains
no code, is a virus, etc.).This submission should be removed because:

Your Vote

What do you think of this article (in the
Intermediate category)?(The article with your highest vote will win this month's coding contest!)
Excellent Good Average Below Average Poor
(See voting log ...)

Other User Comments

There are no comments on this submission.

Add Your Feedback

Your feedback will be posted below and an email sent to
the author. Please remember that the author was kind enough to
share this with you, so any criticisms must be stated politely, or they
will be deleted. (For feedback not related to this particular article, please
click here instead.)

My nonprogramming sites: The Real Estate Crowdfunding Review: Investing tools that cut through the clutter and the hype.
Real information and reviews. Real-time investment feeds. Real profitable. | Dollar candy: Play 60 second puzzles against three other people for real money! Legal in 36 states and overseas.