Time Server Synchronization
8/28/2008
This code sample is named CMTime. It demonstrates how to use Connection Manager to establish a connection to a Time Server, and synchronize the Windows Mobile powered device's internal clock.
Feature Area
Relevant APIs
- ConnMgrReleaseConnection function
- ConnMgrEnumDestinations function
- ConnMgrEstablishConnection function
- TCP sockets
Usage
To run the code sample
Navigate to the solution file (*.sln), and double-click it. By default, the solution file is copied to the following folder:
C:\Program Files\Windows Mobile 6 SDK\Samples\Smartphone\cpp\Win32\CMTime
Microsoft Visual Studio 2005 launches and loads the solution.
Build the solution (Ctrl+Shift+B).
Deploy the solution (F5).
Solutions
The sample consists of two solutions
- CMTime
This is the Windows Mobile 6 Standard application.
- TimeServer
This is a Win32 console application that mimics a Time Server for use with the CMTime device sample. When you run TimeServer.exe the command window will indicate activity when an application connects to get the time.
Remarks
If you want to use this code sample to connect to a Time Server on the Internet, you can set the IP address for that server in g_in_addr. You can substitute the IP address of any Time Server that supports Time Protocol (RFC-868).
Using a Time Server on the Internet requires that your computer be able to access port 37. Depending on your network and proxy server configuration, you may need to ask your network administrator or help desk what you need to do to access traffic on port 37. Generally, this will require you to install or configure a proxy client on your desktop computer. If your network is not allowing port 37 traffic through to your computer, you will see the message "...Finding Connection..." in the CMTime application window, for about one minute followed by the message "Error getting time!"
For more information on Time Servers, see How to Configure an Authoritative Time Server in Windows Server 2003 on MSDN.
Development Environments
SDK: Windows Mobile 6 Standard SDK
Development Environment: Visual Studio 2005.
ActiveSync: Version 4.5.