Prev: Class "COM" not found
Next: SQL Queries
From: "Angus Mann" on 19 Dec 2009 19:13 Hi all. I'w writing a PHP app that is designed to run over a LAN, so internet connection for the server is not really essential. Some users may deliberately not connect it to the internet as a security precaution. But I'd like the app to make use of an internet connection if it exists to check for an update, and notify the user. Is there a simple way for a PHP script to check if it has an internet connection? I thought of this : if(fsockopen("www.google.com", 80)){ // we are connected } Is this OK or is there something better for the purpose?
From: Ashley Sheridan on 19 Dec 2009 19:14 On Sun, 2009-12-20 at 10:13 +1000, Angus Mann wrote: > Hi all. > > I'w writing a PHP app that is designed to run over a LAN, so internet > connection for the server is not really essential. Some users may > deliberately not connect it to the internet as a security precaution. > > But I'd like the app to make use of an internet connection if it exists to > check for an update, and notify the user. > > Is there a simple way for a PHP script to check if it has an internet > connection? > > I thought of this : > > if(fsockopen("www.google.com", 80)){ > // we are connected > } > > Is this OK or is there something better for the purpose? > > > Why can't you put the update on the same LAN server that the app resides? If that is not possible, what about using CURL, and update if it can connect successfully, but don't if it cannot? Thanks, Ash http://www.ashleysheridan.co.uk
From: "Angus Mann" on 19 Dec 2009 19:36 Why can't you put the update on the same LAN server that the app resides? If that is not possible, what about using CURL, and update if it can connect successfully, but don't if it cannot? Thanks, Ash http://www.ashleysheridan.co.uk Since the LAN is remote (many hundreds of miles away) from the source of the update, the only practical way to deliver an update every month or week to multiple users is to make it available for download from a central "update server". I'm just trying to maximize efficiency by checking if an internet connection exists, and abandoning further attempts to check for update availability if it does not. The idea to use CURL seems valid, but it pre-supposes that I know the answer to my own question. To use your suggestion, I'd have to have some mechanism to detect if it "can connect successfully". I'm asking what that mechanism should be, and if the one I've suggested is good, or flawed in some way.
From: Ashley Sheridan on 19 Dec 2009 19:36 On Sun, 2009-12-20 at 10:36 +1000, Angus Mann wrote: > Why can't you put the update on the same LAN server that the app resides? > > If that is not possible, what about using CURL, and update if it can connect successfully, but don't if it cannot? > > Thanks, > Ash > http://www.ashleysheridan.co.uk > > Since the LAN is remote (many hundreds of miles away) from the source of the update, the only practical way to deliver an update every month or week to multiple users is to make it available for download from a central "update server". > > I'm just trying to maximize efficiency by checking if an internet connection exists, and abandoning further attempts to check for update availability if it does not. > > The idea to use CURL seems valid, but it pre-supposes that I know the answer to my own question. To use your suggestion, I'd have to have some mechanism to detect if it "can connect successfully". I'm asking what that mechanism should be, and if the one I've suggested is good, or flawed in some way. > > > > I think the only way to detect if it can connect to the Internet is to see if you can grab a file from somewhere on the Internet. I'd hazard a guess that when operating systems are able to tell you they can "connect to the Internet" they are actually saying they can ping a predetermined remote host. I think checking if PHP can grab a remote file with Curl would be sufficient in this case. Thanks, Ash http://www.ashleysheridan.co.uk
From: John Corry on 19 Dec 2009 19:41
Curl_init() will return a resource or false if it fails, like it would if no Internet connection were present. J Corry Sent from my iPhone On Dec 19, 2009, at 5:36 PM, "Angus Mann" <angusmann(a)pobox.com> wrote: > > Why can't you put the update on the same LAN server that the app > resides? > > If that is not possible, what about using CURL, and update if it can > connect successfully, but don't if it cannot? > > Thanks, > Ash > http://www.ashleysheridan.co.uk > > Since the LAN is remote (many hundreds of miles away) from the > source of the update, the only practical way to deliver an update > every month or week to multiple users is to make it available for > download from a central "update server". > > I'm just trying to maximize efficiency by checking if an > internet connection exists, and abandoning further attempts to check > for update availability if it does not. > > The idea to use CURL seems valid, but it pre-supposes that I > know the answer to my own question. To use your suggestion, I'd have > to have some mechanism to detect if it "can connect successfully". > I'm asking what that mechanism should be, and if the one I've > suggested is good, or flawed in some way. > > > > |