Very nice work. I was planning on making a Perl script to check when the connection is dropped and to reinitiate it as well as do some other things. I think you code will be of some help to me.
BTW
Isn't there a better way to get your IP info such a route. I guess it doesn't make much difference just seems a bit easier to me. Good Luck