Finding Your External IP Address from Within a Clarion Application
I have successfully used the “dip” class from CapeSoft’s great NetTalk templates, but was looking at another way to find my IP address that was not dependent upon their server.
There are many ways to do this, but below I show one that I have put together.
I have control of several hosted sites with several different hosts in different data centers. I have messed a little with PHP.
So, I chose to create a small .PHP file that would return the REQUESTOR’s IP address. I started out returning a well formatted HTTP page with the data buried within the page, then used a Clarion program to connect, retrieve the page, parse the page and display the IP address.
The fetching of the page was done using some code I was given by a great friend, Skip Williams. He had done a lot of WININET programming and had presented some examples at an ETC (East Tennessee Clarion) Conference back in 2004.
My PHP code went thought several versions and I finally ended up with a file that contains only these 5 lines:
<?php //Gets the IP address $ip = getenv("REMOTE_ADDR") ; Echo trim($ip); ?>
This will return an IPv4 address up to 15 characters formatted nnn.nnn.nnn.nnn
Now for the Clarion program. For this, you need to download the .zip file with the project and source.
Because I have more than one hosted account, I decided to have a backup site in case the primary site was offline or otherwise unavailable
So, using Skip’s example, I built a small .PRJ and .CLW to create the demo program. The source, project and PHP file are available in the download file below
The links in the sample code will likely work for a couple of years. But if you have your own site, then you can easily adapt the code and place the .PHP file on your own site.
If you would like to experiment with your OWN site, then for less than $12 per year you can get a great deal here:-
(I use them for a site or two and have been happy with their service.)
Click the image to find out more from UltraSurge. That is just US$11.40 per Year. This will give you lots of room to play with for a project like this.
But you may want to consider their #4 special as below , that allows hosting multiple domain sites and lots more space.
Check out their #4 package at US$36 per Year for 10Gigs of space and unlimited sites.
You do also need a domain name, and that will set you back about $10 per year. I use and recommend Name.com for domain registrations.
This rsvp-ip.zip file contains a CW project file, CW source file and the small .PHP file.
Click HERE to download the file rsvp-ip.zip