php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31308 php_network_getaddresses fails with localhost
Submitted: 2004-12-27 12:18 UTC Modified: 2005-01-10 23:13 UTC
Votes:1
Avg. Score:2.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: the_deppchef at hotmail dot com Assigned:
Status: Closed Package: Sockets related
PHP Version: 5.0.3 OS: Linux 2.4.27 (Debian)
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: the_deppchef at hotmail dot com
New email:
PHP Version: OS:

 

 [2004-12-27 12:18 UTC] 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)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-01-10 02:23 UTC] 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


 [2005-01-10 21:17 UTC] the_deppchef at hotmail dot com
works as expected now
 [2005-01-10 23:13 UTC] tony2001@php.net
User reports the bug is fixed, closing then.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 06:01:30 2024 UTC