note 76781 deleted from mysqli.connect by danielc

From: Date: Thu, 12 Mar 2009 19:52:28 +0000
Subject: note 76781 deleted from mysqli.connect by danielc
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-151800@lists.php.net to get a copy of this message
Note Submitter: martin dot velek at gmail dot com Reason: 0 ---- When you need more(less) timeout, you can use this. This only guarantees that host and port are opened. It is suitable on the very high speed networks(LAN) and where one second is not acceptable. $timeoutInSeconds can be set to any numeric value e.g. "1/2", "0.500","0.1","0.01" etc. -------------------------------------------------------------- function getmicrotime() { list($usec, $sec) = explode(" ",microtime()); return ((float)$usec + (float)$sec); } $time_start = getmicrotime(); $fp = fsockopen("$mysqlHost",$mysqlPort, $errno, $errstr,$timeoutInSeconds); if (!$fp) { //timeout mostly echo "ERR: $errno - $errstr<br>\n"; $time_end = getmicrotime(); $time = $time_end - $time_start; echo "Timeout $time sekund"; } else { fclose($fp); }

« previous php.notes (#151800) next »