View Full Version : Detecting an internet connection without ping

06-26-2005, 06:12 PM
I am running a PHP script on my local server that contacts a live remote server to do uploads and downloads. However, I need to prevent the script from even trying to download or upload to the remote server if there is no internet connection. Due to a faulty LinkSys router, and me lacking the money to replace it, I have to deal with a periodic loss of internet connection when it gets clogged with too many packets or overheats.

Currently I am using a system ping to Google through PHP to detect if there is an active connection. I am wondering, however, if there is a better way to do this.

This PHP script mainly runs on Windows XP for the moment.

06-26-2005, 09:19 PM
How are you connecting to the live server, isn't there some way you can check during the connection process and, if the connection returns false, just don't go any further?

06-27-2005, 03:08 AM
Currently I am using file_get_contents() to download. As for upload, that takes place via FTP. The problem is I haven't figured out how to get detailed errors on what exactly caused the lack of connection.

I may switch to using cURL in place of file_get_contents() so that I can look at the comprehensive cURL errors, but for uploading by FTP I need to find some way to get exactly what status errors occured to prevent the connection or what interrupted the upload.