How to Use Microsoft SENS* for Network Detection

Submit New Article

November 29, -0001 11:00 PM PST



Challenge

Implement the Microsoft System Event Notification Service (SENS) to perform network detection in a mobilized application. Windows* 2000 includes the System Event Notification Service (SENS) to solve many mobile application issues.


Solution

Use the function calls described here to check whether the connection is alive and to ping a specified address. In addition to these simple functions, you can also register with the service to receive events when a connection is made or lost, a destination can be pinged, or when the system changes power state (battery on, AC ON, or battery low).

The APIs for SENS are as follows:

IsNetworkAlive   (lpdwFlags)
IsDesitinationReachable (lpszDestination, pQualityOfSeviceInfo)

 

The event objects are as follows:

ISensLogon:   Logon, Logoff, display locked, display unlocked, screen 
              saver on, screen saver off

ISensLogon2: Fast user switching (sessions) logon/logoff

ISensNetwork: Connection Made / Lost, Destination reachable, Destination reachable no QOS

ISensOnNow: AC Power ON, Battery ON, Battery Power Low

 

There is a very good sample for implementing a network detection application at: http://support.microsoft.com/?id=321381*

The Microsoft SENS APIs, while robust and easy to use, have the following limitations:

  • SENS is a Windows* service and as such, must be running to function properly. On a default Windows XP system this service should be installed and running. A user can disable the service if they wish, however.
  • IsDestinationReachable pings the specified remote address. This API will not work through a firewall or for sites that do not respond to ping requests. If an address is not reachable, the function will not return for seven seconds. This API provides the only method for determining the initial connection speed until the state changes and you receive a notification.
  • SENS can take as long as five minutes to report connection state changes. (VPN connect/disconnect and unplugging of network cable reporting is instantaneous.)
  • SENS has no method for distinguishing a wireless connection from a wired connection.

 

This item is part of a series that addresses t hree different ways of implementing network detection. For the entire series, see the item How to Implement Network Detection for Mobile Applications.


Source

Implementing Network Detection for Mobility