#44335 [NEW]: fsockopen on localhost on Vista
| From: | php at smarinier dot net | Date: | Wed, 05 Mar 2008 11:16:54 +0000 |
| Subject: | #44335 [NEW]: fsockopen on localhost on Vista | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-122956@lists.php.net to get a copy of this message | ||
From: php at smarinier dot net
Operating system: Windows Vista
PHP version: 5.2.5
PHP Bug Type: Network related
Bug description: fsockopen on localhost on Vista
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 bug report at http://bugs.php.net/?id=44335&edit=1
--
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=44335&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=44335&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=44335&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=44335&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=44335&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=44335&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=44335&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=44335&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=44335&r=support
Expected behavior: http://bugs.php.net/fix.php?id=44335&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=44335&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=44335&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=44335&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=44335&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=44335&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=44335&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=44335&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=44335&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=44335&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=44335&r=mysqlcfg