Situation: I’ve put up a lot of tutorials and examples on my blog that use Flash Media Server3. In order to save money, and not mess with hosting, I’ve decided to host my own Flash Media Server here on my PC. I have a residential account with my ISP which means no static IP.
Problem: When my IP address does change my examples will fail because they won’t be able to connect to my home PC.
The first thing I did to mitigate the work of updating the IP address for all my Flex applications that connect to FMS3 is to pull the current IP address from a database record using MySQL and AMFPHP.
That works great. Now all I need to do is make sure that I check my IP address, often, and when I notice that it changes I can just update one record in the database and everything will work again.
But there’s got to be a better way.
Well, It’s simple to write a PHP script that tells me what my current IP address is. You can see a bit of it running if you go to polyGeek.com/myIP.php. Here’s the code:
<?php echo( $_SERVER['REMOTE_ADDR'] ); ?>
So from my PC if I go to a script on my host I can get the value of my current IP address. It would be easy to extend that code to connect to the MySQL database and update the value of the IP address every time. As long as I’m the only person hitting that script it will keep the IP in the database up to date.
Now All I need to do is set something up to run that script fairly often. And it has to run from this PC that I’m on. I can’t use a Chron job to do it.
I can create an AIR app that pings that script on an interval. I must have that app running all the time, but I can make the app minimize to the System Tray on startup so that I don’t actually have to see it on my Task Bar.
The problem with that is I’ve never made an AIR app that minimizes to the System Tray. Actually, I made my first AIR app ever just a few months ago. And, I had never connected an application to a database until this past Spring, 2008. I didn’t have a clue what AMFPHP was. Actually, if you showed me a page of PHP script I wouldn’t be able to tell you what language it was – without the <? PHP ?> tags. And I hardly knew any Flex and just a smattering of Actionscript 3.
It feels good sometimes to sit back and think about “Just what have I learned to do recently.” When I do that it reminds me that, “Though the mountain of knowledge ahead of me may be high so is the mountain that I have already climbed.”
Too often I only look ahead to see what I have left to learn which can be intimidating, even paralyzing with the hugeness of it all. But when I look back and realize the incredible amount to skills and knowledge I already possess the road ahead becomes a little less daunting.
I’m guessing you can relate. Right?
This time last year I wouldn’t have been able to sit down in any reasonable amount of time and completed just one piece of the problem I just solved. Today I did the whole thing in just a few hours – I struggled a bit with the PHP. :-)
I’m really looking forward to the next few months. Lots to do. Lots to learn. I’ll be frustrated, tired, excited, proud, baffled, more frustration and exalted along the way. And enjoy every minute of it.
If something here has proved valuable to you then feel free to drop a couple of bucks in the tip-jar.
