PHP Check online connectivity

  • devilwood
  • Silver Member
  • Silver Member
  • User avatar
  • Posts: 436

Post 3+ Months Ago

I'm wondering the best way to use php to check for online connectivity. So, I'm running a local machine on my development computer. What I want is that while I'm running scripts on my development machine that those PHP scripts ping,opensocket, etc to check to see if my local machine is online so I can then generate a log and email it or save it to a central database of mine. Currently, I just open two mysql_connect resources and push the data, but I would like an additional check for if the machine IS ever offline that an exception is thrown and ignored and the local machine just takes over the logging and the script doesn't time out trying to connect to the central database. My first guess would be to ping or fsockopen any ol' url and just see if it opens it but those hang, IMO, and sometimes never time out properly, especially ping. Any recommendations for an easy-to-implement, reliable way to just see if my connection on my local machine is open?
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • ScienceOfSpock
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 1893
  • Loc: Las Vegas

Post 3+ Months Ago

fsockopen supports a timeout argument, in seconds.
Code: [ Select ]
fsockopen ( string $hostname [, int $port = -1 [, int &$errno [, string &$errstr [, float $timeout = ini_get("default_socket_timeout") ]]]] )
  • devilwood
  • Silver Member
  • Silver Member
  • User avatar
  • Posts: 436

Post 3+ Months Ago

Got it. I've been testing with fsockopen and it should work for me. Thanks SOS.

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 84 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.