Re: checking internet connection

From: Date: Sat, 03 Nov 2001 06:40:24 +0000
Subject: Re: checking internet connection
References: 1  Groups: php.gtk.general 
Request: Send a blank email to php-gtk-general+get-524@lists.php.net to get a copy of this message
Try using fsockopen() to open a connection to the file on the server. You can set the connection timeout on fsockopen() to something sensible like 10 or 15 seconds, the assumption being that if they can't connect to your server in 10 or 15 seconds they probably aren't online (or your server's down:). To prevent the app from freezing during the connection attempt, or while the dailup dialog is open, simply place the following code after the code used to open the connection:
        while (gtk::events_pending())
                gtk::main_iteration();
HTH. At 11:08 PM Friday, 11/02/2001, you wrote:
Hi again, I am working on a download manager for phpdev, basically its there, a PHP-GTK window will check for an XML file on the server and parse this for a list of updates/adons to phpdev , a clist displays these and allows you to select a package and then download using the php ftp functions, everything works so far... My problem is checking if the user is online, to achieve this I just call a test file on the server (I am using Snoopy for this to get over any proxy setting problems) now this works in that if the user is online then my function succsessfully reports this and proceads to download. If however the user is not online... windows opens a 'connect to the internet' dialog, which hangs the app whilst connecting, I do not mind this, but if the user chooses 'cancel' from the 'open network connection' dialog the GTK window 'hangs' and has to be shut down forceably, and obviously this is not ideal. Can anyone suggest a different method for checking the connection status? I can successfully check if localhost is running by requesting a file with no problems , the problem ocurs when the windows dialog appears. Regards Simon Wheeler.
:: geoff ---------- Liquor was invented to prevent the Irish from ruling the world.
			        ~ The Ghost the and Darkness


« previous php.gtk.general (#524) next »