|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits              [2005-01-10 02:23 UTC] sniper@php.net
  [2005-01-10 21:17 UTC] the_deppchef at hotmail dot com
  [2005-01-10 23:13 UTC] tony2001@php.net
 | |||||||||||||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 18:00:01 2025 UTC | 
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)