From: the_deppchef at hotmail dot com
Operating system: Linux 2.4.27 (Debian)
PHP version: 5.0.3
PHP Bug Type: Sockets related
Bug description: php_network_getaddresses fails with localhost
Description:
------------
fsockopen fails when connecting to "localhost" (which worked with earlier
versions e.g. 5.0.2).
connection to "127.0.0.1" still works
Reproduce code:
---------------
<?php
echo '<br>localhost<br>';
$fp = fsockopen ("localhost", 3333, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)<br />\n";
} else {
fputs ($fp, "GET / HTTP/1.0\r\n\r\n");
while (!feof($fp)) {
echo fgets($fp,128);
}
fclose($fp);
}
echo '<br>127.0.0.1<br>';
$fp = fsockopen ("127.0.0.1", 3333, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)<br />\n";
} else {
fputs ($fp, "GET / HTTP/1.0\r\n\r\n");
while (!feof($fp)) {
echo fgets($fp,128);
}
fclose($fp);
}
?>
Expected result:
----------------
Connection refused in both examples, not "php_network_getaddresses:
getaddrinfo failed" when connecting to "localhost"
Actual result:
--------------
ocalhost
Warning: fsockopen() [function.fsockopen]: php_network_getaddresses:
getaddrinfo failed: Name or service not known in /www/html/tcl.test.php on
line 7
Warning: fsockopen() [function.fsockopen]: unable to connect to
localhost:3333 (Unknown error) in /www/html/tcl.test.php on line 7
(1077539444)
127.0.0.1
Warning: fsockopen() [function.fsockopen]: unable to connect to
127.0.0.1:3333 (Connection refused) in /www/html/tcl.test.php on line 18
Connection refused (111)
--
Edit bug report at http://bugs.php.net/?id=31308&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=31308&r=trysnapshot4
Try a CVS snapshot (php5.0):
http://bugs.php.net/fix.php?id=31308&r=trysnapshot50
Try a CVS snapshot (php5.1):
http://bugs.php.net/fix.php?id=31308&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=31308&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=31308&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=31308&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=31308&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=31308&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=31308&r=support
Expected behavior: http://bugs.php.net/fix.php?id=31308&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=31308&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=31308&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=31308&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=31308&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=31308&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=31308&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=31308&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=31308&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=31308&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=31308&r=mysqlcfg