note 31635 added to function.gethostbyaddr
| From: | www dot ad-rotator dot com at rack1 dot php dot net | Date: | Mon, 28 Apr 2003 21:06:24 +0000 |
| Subject: | note 31635 added to function.gethostbyaddr | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-47221@lists.php.net to get a copy of this message | ||
For ad-rotator.com, we need to do a lot of IP lookups, gethostbyaddr is very easy get timed-out and
the script stucks there forever. Here is a fail-safe alternative, 1 sec max for timeout per IP.
function ar_gethostbyaddr($ip) {
$output =
host -W 1 $ip;
if (ereg('.*pointer ([A-Za-z0-9.-]+)\..*',$output,$regs)) {
return $regs[1];
}
return $ip;
}
--
http://www.php.net/manual/en/function.gethostbyaddr.php
http://master.php.net/manage/user-notes.php?action=edit+31635
http://master.php.net/manage/user-notes.php?action=delete+31635
http://master.php.net/manage/user-notes.php?action=reject+31635