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

 ID:               51079
 Comment by:       dontwantanyspam at mailinator dot com
 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: win32 only - Windows XP
 PHP Version:      5.2.12
 Assigned To:      pajoye

 New Comment:

Forgot to mention my operating system. Windows 7 x64.


Previous Comments:
------------------------------------------------------------------------
[2010-03-13 20:22:24] dontwantanyspam at mailinator dot com

I can also confirm that this problem isn't there in PHP 5.3.0. Its there
since 

5.3.1.



Unlike PHP 5.3.0, a 64 bit version of PHP 5.3.1 wasn't available at 

http://windows.php.net/qa/, so I tried compiling it myself. After
compiling I 

noticed that a script that uses
file_get_contents("http://localhost/...";) 

wouldn't work until I change the "localhost" to "127.0.0.1". I didn't
care about 

it much at that time since it seemed like a small problem. But then I
noticed 

that none of the scripts that used mysql were working. I even tried to
log in to 

phpMyAdmin and even that didn't work (same problem described by
thijsputman). So 

I thought that it was probably a bug with the 64 bit binary and
continued using 

PHP 5.3.0. 



But after PHP 5.3.2 was released, I tried compiling it also and noticed
that the 

problem was still there. Thinking that it may be related to mysqlnd
since the 

version used by PHP 5.3.0 is 5.0.5-dev and the one used by PHP 5.3.2 is
5.0.7-

dev, I tried compiling the mysql, mysqli and pdo mysql extensions with
libmysql. 

I has success with the mysql extension only. The mysqli and pdo mysql
extension 

failed to compile with libmysql (there were a lot of build errors).
Anyway, I 

tried the mysql extension compiled with libmysql and noticed that it was
working 

fine! But I needed the mysqli extension to work also and since it failed
to 

compile with libmysql, I messed around some more and finally realized
that it 

was the same problem as with the file_get_contents. So I tried changing
all the 

"localhost" references to "127.0.0.1" and it worked!



Anyway, for whatever reason the mysql extension compiled with libmysql
works 

fine with "localhost" but the one compiled with mysqlnd doesn't. So, I
hope this 

helps you to find and squish the bug thats causing this. :D

------------------------------------------------------------------------
[2010-03-10 12:31:15] thijsputman at gmail dot com

Fair enough :)



The reproduce code provided fails to connect to "localhost" with
fsockopen() in PHP 5.3.2. When using PHP 5.3.0 fsockopen() connects to
"localhost" without problems.

------------------------------------------------------------------------
[2010-03-10 12:03:59] paj...@php.net

It does not depend on PHP only but libmysql or mysql server. Please keep
posting about the socket issue only here as the myslq&IPv6 questions
have been covered numerous times in other reports. The one report per
issue rule is also a good way to do not get distracted, thanks for your
understanding :)

------------------------------------------------------------------------
[2010-03-10 11:38:07] thijsputman at gmail dot com

Agreed, but that's not my point: 



Just like when using fsockopen() to connect to "localhost", I would
expect mysql_connect("localhost") to also attempt to use IPv4,
irrespective of whether "localhost" resolves to [::1] or 127.0.0.1.

This is the same behaviour exhibited by Firefox on my system and
apparently also the behaviour of several other PHP functions, as made
clear in the initial post of this bug.

------------------------------------------------------------------------
[2010-03-10 10:53:40] paj...@php.net

Mysql is not related to this problem, IPv6 is not supported and you have
to apply one of the solutions described here or one of the other
numerous reports about mysql and IPv6.

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


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=51079


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

Reply via email to