Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jan 2005
    Posts
    470
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Question Detecting an internet connection without ping

    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.

  • #2
    Regular Coder
    Join Date
    Feb 2005
    Location
    West Midlands, UK
    Posts
    623
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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?

  • #3
    Regular Coder
    Join Date
    Jan 2005
    Posts
    470
    Thanks
    3
    Thanked 0 Times in 0 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •