|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30374 fsockopen does not timeout on bogus desination
Submitted: 2004-10-09 16:56 UTC Modified: 2004-10-11 12:28 UTC
From: labsy at seznam dot org Assigned:
Status: Not a bug Package: Sockets related
PHP Version: 5.0.2 OS: Windows 2000/XP
Private report: No CVE-ID: None
 [2004-10-09 16:56 UTC] labsy at seznam dot org
This bug has been reported 2 years ago, but it is still present in last 5.0.2 version.
PHP installed on Windows 2000 server or on Windows XP, all with latest service packs. PHP run as ISAPI.

For destination IP $domain in my script, please use some remote machine with IIS 5.0 or IIS 5.1.
Try the script and it should pass.
Now, on REMOTE machine, go and crash IIS service. For example, you may crash it for sure this way:
- install PHP on remotemachine as ISAPI
- in PHP.INI enable some extension, which does not exist - try php_pdf.dll
- start IIS and IIS should hang

Now, run the script again to test hanged IIS machine. Script should exit with FATAL ERROR or in worst case, with IIS hang on your first machine.

Reproduce code:
$domain = ""; //enter some IP - see instructions below!
$port = "80";
$fp = fsockopen($domain,$port,$errno,$errstr,2) ;
if (!$fp){
             $output = '<br>SOCKET: '.$domain.':'.$port.' FAILED responding!';
} else {
             $output = '<br>SOCKET: '.$domain.':'.$port.' responded OK';

Expected result:
fsockopen() should return TRUE or FALSE, but in any case it should exit within set TIMEOUT value (which is 2 seconds in this case).

Actual result:
In case that destination socket is IIS and it is CRASHED or HANGED, the script will not terminate after 2 seconds, but will try open socket until PHP timeout occures.
And additionally - in some cases, if PHP is run on IIS 5.0 or 5.1, script may HANG and LOCK IIS so you need to restart machine. W3SVC stops responding.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-10-11 01:22 UTC]
Does it hang if you try and reach it from linux ?
 [2004-10-11 07:53 UTC] labsy at seznam dot org
Unfortunatelly, I do not have Linux box for testing.

And to make it clear - if we have 2 machines, the only important and relevant is machine with Windows 2000/XP server, which hosts the buggy script.
The other machine might be anything - bug is reproductible when this other machine has web server hanged or crashed, which makes our first machine to hang, too!
 [2004-10-11 12:28 UTC]
You're missing the point, which is that windows is quirky and doesent behave in the same way as all the other operating systems.

Now, if the same script, talking to the same hung win32 server, works from a linux or bsd box there is no bug that we will fix (because win32 is being bad).

If it does work from another OS, we're still not likely to be able to fix it; I've seen this kind of thing with other networking apps on win32; the tcp/ip stack on the server gets confused and only a reboot will fix it.

In either case, this is not something we can or will fix.

PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Thu Apr 02 10:01:23 2020 UTC