IP Address Locator for the Pocket PC

In the excellent book "Making Things Talk" by Tom Igoe (O'Reilly Press, 2007) there's a brilliant project to find the latitude and longitude of a web server based on its IP address, using a PHP script on a website. It's based on the Host IP website, which stores the geographical location of servers. Although their information isn't necessarily accurate or complete (it isn't a commercial venture) the idea of locating a server on the Pocket PC seemed a fun idea. That could easily be done without the PHP bit, but it's a good opportunity to learn how to program web communications in NS Basic on a Microsoft Windows Mobile based Pocket PC using the newObjects control.

Therefore, the KML IP Locator program was written to do just that. However, being able to see the server location on a map or satellite imagery sounded even more fun, so a Keyhole Markup Language (KML) waypoint saving function was added. The waypoint file can be clicked in the file manager to open in Google Maps on the Pocket PC. The program can be seen running in Figure 1, and the reported location of www.nsbasic.com is shown in Google Maps on the Pocket PC in Figure 2.

The KML IP Locator main window.

Figure 1. The KML IP Locator window.

www.nsbasic.com in Google Maps!

Figure 2. www.nsbasic.com in Google Maps.

To use KML IP Locator on a Pocket PC, you first need to install the correct NS Basic runtime files for your device, which you can get by clicking here. Then, download the file below onto your Pocket PC and run it: To use the program all you need do is insert a valid domain name (e.g. www.geocomputing.co.uk) and click the 'Get IP address and server location button'. After a few seconds the country, city, latitude and longitude of the server should appear, or you should be told that the location isn't available. If the location is available, you can use 'SaveKML' in the 'Waypoint' menu to create a KML file to view in Google Maps if you have it installed (or on Google Earth n a desktop PC). However, please remember that the location data is only as accurate as that contained on the Host IP website which we have no control over. Also, it only works for servers which have provided their location information, so you won't be able to find the location of individual computers or users, which is obviously a good thing from a privacy point of view.

Click here to download KML IP Locator for the Pocket PC.

As you may already know, NS Basic apps are encrypted, so that only people who have a copy of NS Basic can read the code. However, KML IP Locator is open-source (GPL) and so a text version is provided here for you to view in a text editor. The code is currently set to communicate with a PHP file (iplocator.php) on the GeoComputing server, but that's just for you to try it out. If you wish to use KML IP Locator for more than just a couple of tests, you will need to download the PHP script (by clicking here) and install it on your own website. The NS Basic code is commented to show you where to change the website address to your own PHP script location.