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

 ID:                 51079
 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:   win32 only - Windows XP
 PHP Version:        5.2.12
 Assigned To:        pajoye
 Block user comment: N

 New Comment:

Oops I hadn't noticed this bug existed and modified #50953 instead.
Sorry.


Previous Comments:
------------------------------------------------------------------------
[2010-08-25 17:57:19] galatmc at gmail dot com

One small note, if this is of any help.  First, I am new to PHP, and ran
into this same issue with PHPMyAdmin and Drupal.  I am on Windows 7 x64,
and found some info on another site.  However, In my case, I was having
an issue with Drupal trying to check http://family-hp/ (my computer
name).  At the time, my hosts file (c:\windows\system32\etc\hosts)
contained:



127.0.0.1       localhost

::1             localhost



When I ran the script, I received:



called connect('family-hp')

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. 

called connect('localhost')

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. 

called connect('127.0.0.1')

Connected to 127.0.0.1 OK 

called connect('www.tonymarston.net')

Connected to www.tonymarston.net OK 



(note: I added a piece of code to indicate how 'connect' was called.)



I made the following changes to hosts:



1. Added a line for family-hp (not sure why I need this, since IE has no
problem resolving my computer name!).

2. Based on information I found on another site, I commented out the
IPv6 loopback.



New hosts file:



127.0.0.1       family-hp

127.0.0.1       localhost

#::1            localhost



Rerun of script:



called connect('family-hp')

Connected to family-hp OK 

called connect('localhost')

Connected to localhost OK 

called connect('127.0.0.1')

Connected to 127.0.0.1 OK 

called connect('www.tonymarston.net')

Connected to www.tonymarston.net OK 



So, if you give hosts a single choice of IPv4 loopback, and no IPv6
loopback, it works!



Mike

------------------------------------------------------------------------
[2010-05-11 13:41:25] anders at ingemann dot de

I can confirm this on Vista x86 with the precompiled 5.3.2 VC6 ts

------------------------------------------------------------------------
[2010-04-28 00:03:32] jbphp at jlb dot nu

We recently upgraded to PHP 5.3.2 and can replicate this problem under
Windows 7 x64.



Luckily the workaround of using '127.0.0.1' in the fsockopen address
instead of 'localhost' is relatively easy but it broke a large volume of
our existing code. Very annoying.



Please fix this asap.

------------------------------------------------------------------------
[2010-03-13 20:26:19] dontwantanyspam at mailinator dot com

Forgot to mention my operating system. Windows 7 x64.

------------------------------------------------------------------------
[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

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


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