#44335 [Opn->Fbk]: fsockopen on localhost on Vista
| From: | jani@php.net | Date: | Tue, 11 Mar 2008 21:54:41 +0000 |
| Subject: | #44335 [Opn->Fbk]: fsockopen on localhost on Vista | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-123191@lists.php.net to get a copy of this message | ||
ID: 44335
Updated by: jani@php.net
Reported By: php at smarinier dot net
-Status: Open
+Status: Feedback
Bug Type: Network related
Operating System: Windows Vista
PHP Version: 5.2.5
New Comment:
Please try using this CVS snapshot:
http://snaps.php.net/php5.2-latest.tar.gz
For Windows (zip):
http://snaps.php.net/win32/php5.2-win32-latest.zip
For Windows (installer):
http://snaps.php.net/win32/php5.2-win32-installer-latest.msi
Previous Comments:
------------------------------------------------------------------------
[2008-03-05 11:16:54] php at smarinier dot net
Description:
------------
A Localhost (or 127.0.0.1) connection with fsockopen failed on Vist
(see simple code later). As far as i can see, this:
- doesn't work with php 5.2.5, 5.2.1, 5.1.6, 5.0.3 : on Vista
- works with PHP 4.4.8 on Vista, or with any PHP on Windows Server
2003.
This is not the same problem as the getaddrinfo(localhost)->127.0.0.1,
wich is a (stupid) security protection from Windows.
Reproduce code:
---------------
<?php
$fp = fsockopen('localhost', 80, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)<br />\n";
} else {
$out = "GET / HTTP/1.1\r\nHost: localhost\r\nConnection:
Close\r\n\r\n";
fwrite($fp, $out);
while (!feof($fp)) {
echo fgets($fp, 128);
}
fclose($fp);
}
?>
Expected result:
----------------
X-Powered-By: PHP/4.4.8
Content-type: text/html
Content<br/>HTTP/1.1 200 OK
Date: Wed, 05 Mar 2008 10:46:31 GMT
Server: Apache/2.2.8 (Win32) PHP/5.2.1
Last-Modified: Sat, 20 Nov 2004 13:16:26 GMT
ETag: "100000000be49-2c-3e9506e38be80"
Accept-Ranges: bytes
Content-Length: 44
Connection: close
Content-Type: text/html
<html><body><h1>It works!</h1></body></html>
Actual result:
--------------
PHP Warning: fsockopen(): unable to connect to localhost:80 (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
) in C:\PHP\test.php on line 2
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. (10060)<br />
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=44335&edit=1