Re: Cheap Ping

From: Date: Fri, 13 Apr 2007 19:37:51 +0000
Subject: Re: Cheap Ping
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-252888@lists.php.net to get a copy of this message
At 11:16 PM -0600 4/12/07, ccspencer@softhome.net wrote:
I am trying to find a simple way to test to see if a web site is up or not.
At 4/13/2007 08:56 AM, tedd wrote:
Try: if ($unix) { system ("ping -c$count -w$count $host"); system("killall ping"); } else { system("ping -n $count $host"); }
What's a circumstance in which one would want to ping without getting a return value? Short of attempting a denial of service barrage? Really, I'm not being snide, just curious. According to the Fingerlicking Manual (OK, now that was arguably snide), you have two opportunities to get return values from system() -- the last command line string as the function return value and a status byte returned in the second parameter. The example provided is: // Outputs all the result of shellcommand "ls", and returns // the last output line into $last_line. Stores the return value // of the shell command in $retval. $last_line = system('ls', $retval); http://php.net/system Googling, I came up with other methods including: PHP Ping (using socket functions) by Philip Jensen http://www.planet-source-code.com/vb/scripts/ShowCode.asp?lngWId=8&txtCodeId=1786 Pinging a remote host in PHP (using PEAR) http://builder.com.com/5100-6371-5234592.html What's a preferred method? Regards, Paul __________________________ Paul Novitski Juniper Webcraft Ltd. http://juniperwebcraft.com

« previous php.general (#252888) next »