note 45587 added to function.fsockopen
| From: | MichaelBrown at osu1 dot php dot net | Date: | Sun, 12 Sep 2004 02:02:17 +0000 |
| Subject: | note 45587 added to function.fsockopen | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-76496@lists.php.net to get a copy of this message | ||
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....
----
Manual Page -- http://www.php.net/manual/en/function.fsockopen.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+45587
Delete -- http://master.php.net/manage/user-notes.php?action=delete+45587&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+45587&report=yes
Search -- http://master.php.net/manage/user-notes.php