|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2010-02-08 11:06 UTC] tony at marston-home dot demon dot co dot uk
Description: ------------ When are you going to provide a proper answer for post http://bugs.php.net/bug.php?id=50953 ? I have removed the IPv6 entries in my hosts file, but the problem is still there. Reproduce code: --------------- function connect($host) { $faultcode = null; $faultstring = null; $conn = fsockopen($host, 80, $faultcode, $faultstring, 20); if (!$conn) { echo 'faultcode=' .$faultcode .', faultstring=' .$faultstring ."\n"; } else { echo "Connected to $host OK\n"; } // if return $conn; } // function $result = connect('localhost'); $result = connect('127.0.0.1'); $result = connect('desktop'); $result = connect('www.tonymarston.net'); Expected result: ---------------- I expect to see the message "Connected to <host> OK" for all values of host. Actual result: -------------- Warning: fsockopen(): unable to connect to localhost:80 faultcode=10060, faultstring=A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. Connected to 127.0.0.1 OK Connected to desktop OK Connected to www.tonymarston.net OK PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Nov 04 21:00:01 2025 UTC |
There is no special-case code in PHP for localhost. Try: print_r(gethostbynamel('localhost'));print_r(gethostbynamel('localhost')); produces the following: Array ( [0] => 127.0.0.1 )