Edit report at http://bugs.php.net/bug.php?id=50953&edit=1

 ID:                 50953
 Updated by:         cataphr...@php.net
 Reported by:        tony at marston-home dot demon dot co dot uk
 Summary:            fsockopen will not work on 'localhost'
 Status:             Assigned
 Type:               Bug
 Package:            Sockets related
 Operating System:   Windows XP
 PHP Version:        5.2.12
 Assigned To:        pajoye
 Block user comment: N

 New Comment:

This is indeed a bug.



The problem is that PHP doesn't detect a connection was actively refused
and instead times out on it.



The scenario where the address has both ipv4 and ipv6 addresses, the
service is only listening on ipv4 and ipv6 has precedence results in:



a) trying ipv6

b) time out

c) fail



instead of



a) trying ipv6

b) connection refused

c) trying ipv4

d) success



I've attached a patch that fixes the issue.


Previous Comments:
------------------------------------------------------------------------
[2010-09-07 10:26:47] cataphr...@php.net

The following patch has been added/updated:

Patch Name: connect_fix_win32
Revision:   1283848007
URL:       
http://bugs.php.net/patch-display.php?bug=50953&patch=connect_fix_win32&revision=1283848007

------------------------------------------------------------------------
[2010-02-12 14:22:47] tony at marston-home dot demon dot co dot uk

If IPv6 support is enabled in the operating system it does NOT mean that
only IPv6 addresses are allowed, it means that both IPv5 and IPv6
addresses are supported.



All of my web browsers (IE, Firefox, Opera, Safari) have no problem in
translating 'localhost' to '127.0.0.1'.



The PHP gethostbyname() function has no problem in translating
'localhost' to '127.0.0.1'.



The PHP cURL extension has no problem in translating 'localhost' to
'127.0.0.1'.



fsockopen() when running in PHP 5.3.0 has no problem in translating
'localhost' to '127.0.0.1'.



So why does fsockopen() in php 5.2.12 have a problem?

------------------------------------------------------------------------
[2010-02-10 11:27:25] tony at marston-home dot demon dot co dot uk

This has got nothing to do with IPV6 addresses as my hosts file does not
contain anf IPV6 addresses. All it has is as follows:



127.0.0.1   localhost



Every other piece of software on my PC uses 'loalhost' without a
problem, so should fsockopen in PHP. Curl can manage it, so why not
fsockopen.



I have the same setup on another PC which runs Windows XP with IPV6
support and PHP 5.3.0, and it does not have a problem with 'localhost',
so this is a genuine bug in 5.2



Do not keep telling me that you have already addressed this issue in
other posts because you have not. You nhave suggested removing any IPV6
entries from the hosts file, which I have done, but this does not fix
the problem.



If gethostbyname() can work with 'localhost' then why can't fsockopen()?

------------------------------------------------------------------------
[2010-02-10 11:06:08] paj...@php.net

It works just fine here using localhost and ipv4.



You are clearly experiencing the IPv6 problem described in a good dozen
bugs here (with solutions).



I'm sorry if it is not acceptable but we can't do anything about that,
see the other reports for a complete and detailed explanation.

------------------------------------------------------------------------
[2010-02-10 10:57:11] tony at marston-home dot demon dot co dot uk

THIS IS NOT BOGUS, IT IS A GENUINE BUG!!!



If print_r(gethostbynamel('localhost'));  produces the following:



Array

(

    [0] => 127.0.0.1

)



then why can't fsockopen connect to 'localhost'? It is a valid name
which is recognised by every other piece of software on my computer, so
there is no good reason why fsockopen should have a problem with it.



I have another PC which runs 5.3.0 where fsockopen does not have a
problem with 'localhost', therefore there is a bug in 5.2

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    http://bugs.php.net/bug.php?id=50953


-- 
Edit this bug report at http://bugs.php.net/bug.php?id=50953&edit=1

Reply via email to