Chapter 7. Connection Manager

Operator! Give me the number for 911!

?Homer Simpson, The Simpsons

The last chapter described how to establish and interact with a connection to a remote server using the Remote Access Service (RAS). Although using the RAS APIs provides you with low-level functions to establish a connection with a server and get status information about it, a variety of aspects about that connection can change, depending on what type of network resource you are accessing. This is especially true on mobile devices such as Pocket PC, for which connectivity and authorization requirements can constantly shift depending on your current environment and what you are requesting.

Consider what happens when you try to access an HTTP resource that is located on the Internet. Whether you are dialed into your Internet service or on a wireless LAN at the local coffee shop, the device merely needs to establish a connection to the Internet to download the request. What happens, however, if you make the same request while you are at work and are connected to the corporate network, which is most likely under a firewall? Without having the user authentication information that is passed to the proxy server, the request will fail. Managing all of the various connection types that a user might have would be a nightmare for every individual application developer.

This is where the Pocket PC Connection Manager comes in?it is the best way to manage remote connections (see Figure 7.1).

Figure 7.1. Pocket PC Connection Manager


It is probably easiest to think of the Connection Manger as a centralized location that is used for the configuration of all possible network connections that the device can make. What this accomplishes is a simplified user experience?the user needs to configure what a "Work" connection is only once in order for all networking applications to use it. In addition, the Connection Manager can make some calculations about the cost, latency, and bandwidth required for the request, in an attempt to determine the best type of connection to make in order to get the network resource that you've requested.

If you are planning to develop any applications that require network communications, you will most likely want to have them use the Connection Manager to establish and schedule network connections. By doing so, all of the specific details?including dialing parameters, proxy information, VPN authentication, and so on?are handled for you, provided that the user has already configured his or her device. All you need to do is send a request to the Connection Manager to either establish or close a connection.

To use the Connection Manager API functions within your application, you need to include the headers connmgr.h and connmgr_proxy.h, and link with the cellcore.lib library.