= time()) { $found = self::checkService($host, $port, $end - time()); if ($found) { return TRUE; } usleep($interval_usec); } return FALSE; } /** * Check whether a TCP service is available on $host and $port */ public static function checkService($host, $port, $serverConnectionTimeOut) { $old_error_reporting = error_reporting(); error_reporting($old_error_reporting & ~E_WARNING); try { $fh = fsockopen($host, $port, $errno, $errstr, $serverConnectionTimeOut); if ($fh) { fclose($fh); error_reporting($old_error_reporting); return TRUE; } } catch (Exception $e) { } error_reporting($old_error_reporting); return FALSE; } }