#31308 [Fbk->Opn]: php_network_getaddresses fails with localhost
ID: 31308
User updated by: the_deppchef at hotmail dot com
Reported By: the_deppchef at hotmail dot com
-Status: Feedback
+Status: Open
Bug Type: Sockets related
Operating System: Linux 2.4.27 (Debian)
PHP Version: 5.0.3
New Comment:
works as expected now
Previous Comments:
------------------------------------------------------------------------
[2005-01-10 02:23:01] sniper@php.net
Please try using this CVS snapshot:
http://snaps.php.net/php5-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php5-win32-latest.zip
------------------------------------------------------------------------
[2004-12-27 12:18:54] the_deppchef at hotmail dot com
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 this bug report at http://bugs.php.net/?id=31308&edit=1
Thread (4 messages)