note 45587 deleted from function.fsockopen by nlopess
| From: | nlopess@php.net | Date: | Sun, 12 Sep 2004 08:16:05 +0000 |
| Subject: | note 45587 deleted from function.fsockopen by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-76504@lists.php.net to get a copy of this message | ||
Note Submitter: Michael Brown
----
Another important note about fsockopen! If your connecting to an URL that does not resolve, the
function will not timeout (all I've tested is under FreeBSD).
After many hours wasted, theres a Workaround:
use gethostbyname(), before you make your fsockopen() request.
$ip=gethostbyname($str);
if($ip==$str){
echo "Lookup failed.";
exit;
}else{
echo "IP is $ip";
}
Unfortunately there's a downside. The timeout for me was 90 seconds (under FreeBSD), and there
appears to be no way to change this. I really wish there was better timeout code for these
functions! Its probably easier to use curl....