Take Advantage of the ActiveSync Pass-through Connection

 

Microsoft Corporation

June 2002

Summary: New in Microsoft ActiveSync 3.5 you'll find the pass-through connection capability. This enables a Pocket PC 2002 connected to a desktop PC to share the desktop PC's Internet or network connection. (10 printed pages)

Applies to:
   Microsoft® Windows® Powered Pocket PC 2002
   Microsoft ActiveSync® version 3.5

Contents

Internet Connectivity Out of the Box
Pass-through Connections Under the Hood
Scenarios
Web Application Development
eMbedded Visual Basic and Pass-through Connections
Mobile Databases and Pass-through Connections
Conclusion

Internet Connectivity Out of the Box

Pass-through connections give you the ability to use the desktop PC's Internet connectivity from the Pocket PC. This means that you can use your Pocket PC while it is cradled to surf the Web, access POP3 and IMAP e-mail accounts, and so on. Before pass-through connections existed you had to use a separate Ethernet adapter or a modem to get your Pocket PC online. Some daring users even tried installing and configuring third-party proxy servers on the desktop PC, often without success. With pass-through connections Internet connectivity now comes with the Pocket PC, right out of the box.


Figure 1: Surfing the Web from the cradle

No, don't worry! This article is not about using pass-through connections to surf the Web from your Pocket PC while it is cradled and sitting right next to your desktop PC! Instead, I would like to highlight the opportunities the ActiveSync pass-through connection brings to you, as a developer, in making it possible to design and develop system and application architectures that bring remote infrastructure closer to your users. First, let's take a look under the hood!

Pass-through Connections Under the Hood

A cradled Pocket PC has a Transmission Control Protocol/Internet Protocol (TCP/IP) connection to the desktop PC. Figure 2 illustrates what happens when the Pocket PC opens a connection to a server beyond the desktop PC.


Figure 2. ActiveSync funnels TCP/IP traffic to and from the Pocket PC

  1. The Pocket PC sends the request to open the connection through ActiveSync.
  2. ActiveSync opens a TCP/IP connection to the server on behalf of the Pocket PC.
  3. Data from and to the server is funneled through ActiveSync.

To the remote server, the communication with the Pocket PC appears to be with the desktop PC. The calls to and from the Pocket PC utilize the desktop PC's IP address. This means that the pass-through connection cannot forward calls to the Pocket PC from anyone or anything on the network. The communication has to be initiated by the Pocket PC.

Another consequence of the relationship between the desktop PC and Pocket PC is that if the desktop PC is behind a firewall, the Pocket PC is also restricted by the firewall. Also, if the desktop PC is running an IP-level proxy client to go through the firewall, such as Microsoft WinSock Proxy Client, then the Pocket PC will also be able to go through the firewall.

The communication is based on TCP, which means that the following communication protocols are supported: HTTP, HTTP with Secure Sockets Layer [SSL], IMAP, and POP3. (The following IPs are not supported: User Data Protocol [UDP], Internet Control Message Protocol [ICMP], Point-to-Point Tunneling protocol [PPTP], and file shares.)

Scenarios

I am sure that you have already figured out a number of ways to take advantage of pass-through connections. If not, here are example scenarios:

Health care: Medical staff can use Pocket PCs to have up-to-date patient records when meeting patients in the nursing ward. Patient data that is collected daily, such as temperature, blood pressure, and general conditions are entered directly into the Pocket PC's local database. After the rounds, the doctors and nurses cradle their Pocket PC, and using a pass-through connection, they can synchronize directly with the remote server without having to put any data temporarily on the desktop PC.

Manufacturing: Quality Assurance teams in production plants can create their inspection reports digitally, without tedious paper work. When they are done, the can cradle their Pocket PCs and have the Pocket PC application instantiate server objects and pass each report over to the remote server.

Consumer: Companies that deliver consumer services can make information available to users of connected Pocket PCs in new ways. For example, by developing and exposing Web Services from their Web server that returns current (enter your favorite online service here!) information, they can allow a Pocket PC application to connect to their server, call the Web Service, and retrieve the (enter your favorite online service here!) information. This scenario might provide the basis for subscription models in which the company subsidizes Pocket PCs in order to get subscribers in return.

Software Distribution (horizontal): The software distribution scenario is horizontal, which means that it applies to any industry. Software distribution is a challenge already for desktop PC—based applications. This challenge is significantly bigger with Pocket PCs as they are more … mobile. By making prepared cabinet (.cab) files available on an intranet or Internet page, the user can cradle the Pocket PC at a terminal running ActiveSync, go to that page, click the link to the .cab file, and get the newest version of the application. Figure 3 illustrates what happens when the user taps a link to a .cab file.


Figure 3. Online software distribution to Pocket PCs

These were just a few scenarios that illustrate how you can take advantage of a pass-through connection. In my opinion, pass-through connections might be close to being the "magic silver bullet" of connected Pocket PC applications.

Web Application Development

More and more Web sites get visited by more and more Pocket PC users who go there using their Pocket PCs. As you design and develop your Web site you should start to plan how to support these visitors. There are a couple of ways to transform Web pages to fit the smaller screen of a Pocket PC.

A pass-through connection can help you design and debug the way Web pages are displayed on a Pocket PC. You just need to cradle the Pocket PC to your desktop PC and start surfing.

I illustrate how this can be done by sharing the following ASP-code snippet. The code determines what type of Web browser requests the page and then displays different content depending on the type of Web browser.

' Device Indicators
Public IsPPC, IsMME, IsThinClient
IsPPC = (InStr(Request.ServerVariables("HTTP_USER_AGENT"), "Windows 
CE") > 0)
IsMME = (InStr(Request.ServerVariables("HTTP_USER_AGENT"), "MME") > 0)
IsThinClient = (IsPPC Or IsMME)

The uppermost part of Web page looks like this on the desktop PC:


Figure 4. Microsoft Internet Explorer on the desktop PC

The same Web page looks like this on the Pocket PC:


Figure 5. The same Web page viewed Pocket Internet Explorer on the Pocket PC

eMbedded Visual Basic and Pass-through Connections

You can design and develop richer applications using Microsoft eMbedded Visual Basic® that also can work without a connection to a desktop PC or an online connection to a remote server. This is where I believe many solutions will benefit from using a pass-through connection.

First, I'd like to show you a simple test application that determines if the Pocket PC has a connection that can be used for calling remote servers. Follow these steps:

  1. Create a new Pocket PC 2002 project.
  2. Add a reference to the WinSock Control 3.0 (see Figure 6).

Figure 6. Add a reference to the WinSock Control 3.0

  1. Add one label to the form and call it lblIPAddress.
  2. Add one command button to the form and call it cmdGetIP.
  3. Add a WinSock control to the form.
  4. Add the following code to the form:
Option Explicit

Private Sub cmdGetIP_Click()
' Get local IP Address
' Known bugs:
' Version   Date   Who Comment
' 00.00.000 011104 ASJ Created
'*****************************

    lblIPAddress.Caption = WinSock1.LocalIPEnd Sub

Private Sub Form_OKClick()
' End application
' Known bugs:
' Version   Date   Who Comment
' 00.00.000 011104 ASJ Created
'*****************************
    App.E
End Sub

When you run the application and the Pocket PC does not have a connection or is cradled, you will learn the Pocket PC's local IP address is 127.0.0.1. If it is cradled, then you will see what's in Figure 7.


Figure 7. The local IP address from a cradled Pocket PC

You can make an application behave differently by learning the local IP address. For example, if the Pocket PC does not have a connection, then you connect and use a local database. If the Pocket PC does have a connection, then you can connect and use the remote database or remote components directly. In addition, middleware products that make life easier for enterprise developers, for example Odyssey Software CEfusion and ViaXML, will make use of the a pass-through connection's ability to provide Internet connectivity.

Mobile Databases and Pass-through Connections

Microsoft SQL Server™ 2000 Windows® CE Edition (SQL Server CE) provides two methods to reach remote SQL Server 2000 databases: remote data access and merge replication. Both methods require a TCP connection to the network, as they use the HTTP protocol.

As a pass-through connection provides a TCP connection to the network using the desktop PC's connection, you can design and develop Pocket PC applications that rely on the connectivity options of SQL Server CE.

My last sample will show how SQL Server CE and Remote Data Access utilize the connection provided by the desktop PC to connect to, and push and pull data to and from the remote SQL Server. The illustration is a Pocket PC application that I have called Trip Anyplace. Trip Anyplace helps you keep track of trips you have made (origin and destination) and mileage. You can then push that data up to the remote SQL Server, which could be your company's database for business trips.

Figure 8 shows how to enter a new trip. You enter cities, dates, and distance.


Figure 8. New trip

When you have entered all your trips you can synchronize with the remote SQL Server. Figure 9 shows the Synchronize form.


Figure 9. Synchronizing my trip data

The following code snippet shows how the data is pushed up to the remote server from the Pocket PC:

Private Sub pPushbaTrip()
' PUSH up the local data
' Known bugs:
' Version   Date   Who Comment
' 00.00.000 011030 ASJ Created
'*****************************

    On Error Resume Next

    paco.Close
    psqlRDA.Push "baTrip", RDA_CONNECT_STRING
    paco.Open PROVIDER_STRING & "; " & DATA_SOURCE_STRING
        
End Sub

The psqlRDA object is a Remote Data Access object. It relies on HTTP communication, provided by a pass-through connection.

The unique aspect of this sample is that I have made a SQL Server available on the public Internet, so that you can try out the sample application live. You can download Trip Anyplace and start using it right away!

You first need to create a new user profile to use Trip Anyplace.

Conclusion

Pass-through connections are a powerful and welcome addition to ActiveSync 3.5 and Pocket PC 2002. It's definitely going to connect many Pocket PCs to the Internet and thereby enable many new mobile solutions!