Please login or register.

Login with username, password and session length

Author Topic: Free Vb2008 express Ip address - FTP upload - router recycle program  (Read 9521 times)

EL34

  • Hero Member
  • *****
  • Helpful Post Rating: 21
  • Posts: 278
    • My X-10 projects

When I am not at home, I use Remote Desktop connection to log onto a computer at home and monitor several things like X10 activity, Video security cameras, etc

The problem always is that your IP address can change for various reasons, unless you have a fixed IP.
The other problem I have very rarely, is that my DSL modem/Router will lock up during heavy thunderstorms, even though it is on a UPS battery backup.
I think that mild surges on the phone lines cause that,  and so I have to power off the router and power it back on to get my DSL internet connection going again.

I am going out west on vacation soon and so I thought it was about time I wrote a program that can take care of the situations mentioned above.
I need to stay in touch with my home computers and Murphy's law says that things will go wrong the minute I leave the house on vacation.

I have created a VB.net program using VB 2008 express that you can download and experiment with.
Unzip the whole project and then change the variables that need to be changed.
I have added lots of comments, so it should be easy to personalize the program.

Here's how it works:
The program goes to whatsmyip.com at an interval, (set by you, I do it once an hour).
It gets a small .txt file from whatsmyip.com that contains your main IP address.

It saves that text file to your local hard drive.
This file gets overwritten every time the program goes to get your IP again.
It then opens that text file and reads your IP.

It saves your IP and other status info to another file on your hard drive.
This  status file gets uploaded via FTP to a web server.
If your IP is the same as last time it checked, it does not bother to FTP upload the file again.
You can then use a browser anywhere in the world to find out what your current IP address.

Now, if the program cannot get the IP file from whatsmyip.com, it will timeout after an interval you can set.
The program will retry the file download as many times as you set it to.
I have it set to retry 3 times with a 30 second timeout for each try

It could be that your router is down or that web site is down, or your ISP is down.
I have not spent any time trying to narrow down why the connection timed out, but this could be improved.

If after so many retries, the program cannot fetch the IP file from whatsmyip.com, it will recycle the router power off and then on via and X10 command.
I just plugged my router into an appliance module and I have the program variable set to module h16, but you can change it to any valid x10 module number.

After the program turns the router power back on, it will wait a certain interval and then try to download the IP file again from whatismyip.com.
If the router was the problem, it should fetch the file.
If your ISP is down or the whatsmyip.com page is down, it will go back into the timeout loop stuff again.
I suppose the program could also check to see if google.com or some other pages were up and that would eliminate the whatsmyip.com page being down as the problem.

There is also a small browser window below the main status window that will display the status file on the server.

If you do not have X10, you can remove or bypass the code that references it.
It still is a handy program to just have your IP uploaded via FTP to a web server at an interval.

At the bottom of the code is where all the variables are set.
You will have to change things like FTP server addresses, FTP username, FTP password, timeouts, retries, X10 module names, etc.

Anyone that comes up with any really cool improvements, I hope will share those.

Here's a couple screen shots of the status file info and what the browser file looks like





Here's the link to the VB2008 express zipped up project file.
http://www.el34world.com/Misc/home/Files/CopyofIpaddress.zip
« Last Edit: July 06, 2009, 02:15:10 PM by EL34 »
Logged
W10 - CM15A - AHP 3.301 - i Witness - MyHouse online - Smart Macros - SDK using Visual Basic express 2008
My X10 page-> http://www.el34world.com/Misc/home/X10_0.htm

EL34

  • Hero Member
  • *****
  • Helpful Post Rating: 21
  • Posts: 278
    • My X-10 projects
Re: Free Vb2008 express Ip address - FTP upload - router recycle program
« Reply #1 on: July 16, 2009, 09:38:11 AM »

I actually ended up coming up with a much simpler solution to logging my IP address.

I have two web sites on two different servers.
I found a simple PHP script that will tell you what your IP is when you go to that address in your browser.
It will also write a small file on the server at the the same time you start the PHO file with your browser.

I now just have my VB2008 IP address program run that php program on my web site every hour on a timer.
Then if I want to know my IP while away from home, I have my web browser open the file on the server that the PHP program writes.

This only works if you have a web site/server on the web somewhere and you are allowed to run php scripts on your server.
If you don't, maybe you can get a friend to let you have a tiny bit of space on their server.
Most ISP's give you a small amount of web space free with your internet service package, but I am not sure if you are allowed to upload and run php stuff on your free web space?

This solution ended up being much simpler than downloading a text file from whatismyip.com and then parsing the file, etc
Also, I had trouble with whatismy ip.com being down quite a bitand so the IP address program would fail me.
Logged
W10 - CM15A - AHP 3.301 - i Witness - MyHouse online - Smart Macros - SDK using Visual Basic express 2008
My X10 page-> http://www.el34world.com/Misc/home/X10_0.htm

jeffdharlan

  • Full Member
  • ***
  • Helpful Post Rating: 1
  • Posts: 72
  • My home doesn't take sick days
Re: Free Vb2008 express Ip address - FTP upload - router recycle program
« Reply #2 on: August 05, 2009, 01:13:49 PM »

My 2 cents:  You could spend $24.99/year and get the Dynamic Update Client from here: http://www.no-ip.com (http://www.no-ip.com/downloads.php?page=win).  You run the .EXE. as a background service ON YOUR OWN SERVER and it will check to see if your IP has changed and update your registrar DNS information immediately.  I have used this app for several years with absolutely no problems.

It's cool you worked out a solution for yourself!  I will have to see it in action soon and maybe save some cash!
Logged
What has your home done for you today?

EL34

  • Hero Member
  • *****
  • Helpful Post Rating: 21
  • Posts: 278
    • My X-10 projects
Re: Free Vb2008 express Ip address - FTP upload - router recycle program
« Reply #3 on: August 05, 2009, 01:18:22 PM »

I have my app running as a service also.
Been running solid for a month or so and has worked out nicely.

I use remote desktop sharing from anywhere to get onto my server at home and check X10 stuff, video security, etc.

It worked out way easier using the simple .php program on my web servers.

The router has gone down a couple times from storms and my app reboots it using an appliance module.
Logged
W10 - CM15A - AHP 3.301 - i Witness - MyHouse online - Smart Macros - SDK using Visual Basic express 2008
My X10 page-> http://www.el34world.com/Misc/home/X10_0.htm
 

X10.com | About X10 | X10 Security Systems | Cameras| Package Deals
© Copyright 2014-2016 X10.com All rights reserved.