Windows Mobile devices come with an integrated Terminal Services client (also known as Remote Desktop Protocol, RDP). This client allows you to connect to any Remote Desktop-enabled machine like Windows XP Professional, Windows Server and Linux (another here). Actually a tempting idea to connect to your home machine if you're abroad. You just need a some kind of internet connection.
If there are multiple machines in a firewalled network the only public IP address known on the internet is the one of the router. The default server port for RDP connections is port 3389 (TCP protocol). RDP clients use this port when connecting to a RDP server. What happens if an internet user (RDP client) connects to port 3389 on the public IP of the router? If the firewall is set up correctly, nothing, i.e. the connection is refused. To enable Remote Desktop connections the network administrator has to configure a port mapping. The port mapping basically tells the firewall to open a specific port and route all data from this port to a specific machine on the internal network (for example your Windows XP box). If two users want to expose their machines to the internet the administrator has to open two ports, because a single port is always attached to a single internal machine. See the illustration below for a general overview.
The Failure of the Windows Mobile RDP Client
To connect to the first machine ("Your Computer") from the internet the user has to tell its RDP client to simply connect to the firewall (because it's the machine with the public IP address). Because 3389 is the default port this actually translates to ServerName:3389, where ":" delimits the server name from the port number. To connect to "Another Computer" the address is ServerName:3390.
This is where the RDP client of Windows Mobile fails. It just won't accept servers with appended port numbers.
The First Approach
It's actually possible to change the behavior of the Remote Desktop client to connect to non-standard ports like 3390 or any other by applying a registry hack.
- Open the device registry using a registry editor
- Open the key
HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Client\Default\
- Create an entry of type DWORD, called
- Set the value to the required port number (3390 in the case above)
It's actually a very cumbersome task to edit the registry, especially if you're changing port numbers fairly often because you need to connect to different machines. After proof-reading Torsten's book on Windows Mobile development I thought this would be an easy to automate task.
I've written a little helper application that sets the registry values for you. I've tested it on my Axim x51v and inside the emulators of Visual Studio 2005. It's a .NET Compact Framework 1.0 application so you most likely don't have to install the .NET runtime on Windows Mobile 5.0 devices.
Download the RDP Port Switcher Setup CAB. Feel free to add your own functionality, source code is available.