Jim Lucas-2 wrote: > > Richard Lynch wrote: >> On Fri, April 13, 2007 12:20 am, Jim Lucas wrote: >>>> Is there some way I can set a shorter limit? >>> http://us.php.net/manual/en/function.stream-set-timeout.php >> >> Bzzzt. >> >> That's for an already-opened stream. >> >> :-) >> > I figured that the op would figure that part out and possibly change his > approach to use fsockopen > instead of file_get_contents > > -- > Enjoy, > > Jim Lucas > > Different eyes see different things. Different hearts beat on different > strings. But there are times > for you and me when all such things agree. > > - Rush > > the following from http://de.php.net/manual/en/function.socket-create.php#60438 (slightly modified) works well on my test laptop(w2k,php5.2.1): function ping($host) { $package = "\x08\x00\x19\x2f\x00\x00\x00\x00\x70\x69\x6e\x67"; $sock = socket_create(AF_INET, SOCK_RAW, 1); /* timeout 0.2 seconds */ socket_set_option($sock, SOL_SOCKET, SO_RCVTIMEO, array('sec' => 0, 'usec' => 200000)); socket_connect($sock, $host, null); socket_send($sock, $package, strlen($package), 0); $TS = microtime(1); if(@socket_read($sock, 255)) { return microtime(1) - $TS; } else { return -1; } socket_close($sock); } -- View this message in context: http://www.nabble.com/Cheap-Ping-tf3569802.html#a9989132 Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php