Introduction
The primary purpose of the article is to centralize and automate the establishment and management of the network connections on a device. Applications on the device use the Connection Manager to establish or schedule a network connection. The Connection Manager handles the details of the connection; the application simply informs the Connection Manager of the network type to use for the connection (the Internet, for example).
When an application requests a network connection, the Connection Manager first retrieves all of the possible connections from a set of Connection Service Providers (CSPs). The Connection Manager then associates a set of costs with these routes and ultimately determines the optimal connection based on cost, latency, bandwidth, and other factors. Finally, the Connection Manager queues the requested connection and uses the CSPs to establish the connection at the appropriate time.
Connection Manager takes care of everything, i.e., all connections are made to networks:
- "The Internet"
- "My Corporate Network"
ADD Header file
#include <objbase.h>
#include <initguid.h>
#include <connmgr.h>
In Editor, go to Project>Settings:
Go to Link tab
Object/Library modules:
cellcore.lib
Code
Make the connection
CONNMGR_CONNECTIONINFO connInfo;
HANDLE hConnection;
connInfo.cbSize = sizeof(connInfo);
connInfo.dwParams = CONNMGR_PARAM_GUIDDESTNET;
connInfo.dwFlags = 0;
connInfo.dwPriority = CONNMGR_PRIORITY_USERINTERACTIVE;
connInfo.bExclusive = false;
connInfo.bDisabled = false;
connInfo.guidDestNet = IID_DestNetInternet;
connInfo.hWnd = NULL;
connInfo.lParam = (LPARAM)0;
ConnMgrEstablishConnection(&connInfo , &hConnection);
Close the connection
ConnMgrReleaseConnection(hConnection, 1);
History
- 3rd October, 2006: Initial post