Share via


Time Server Synchronization

Windows Mobile SupportedWindows Embedded CE Not Supported

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

Usage

To run the code sample

  1. 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.

  2. Build the solution (Ctrl+Shift+B).

  3. 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.

See Also

Reference

Connection Manager Helper

Concepts

Code Samples for Windows Mobile