|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #37517 timeout option of fsockopen seems to be ignored
Submitted: 2006-05-19 11:14 UTC Modified: 2006-06-03 01:00 UTC
Avg. Score:5.0 ± 0.0
Reproduced:3 of 3 (100.0%)
Same Version:3 (100.0%)
Same OS:1 (33.3%)
From: gzaboy at hotmai dot com Assigned:
Status: No Feedback Package: *Network Functions
PHP Version: 5.1.4 OS: windows 2003 server
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: gzaboy at hotmai dot com
New email:
PHP Version: OS:


 [2006-05-19 11:14 UTC] gzaboy at hotmai dot com
the timeout option of fsockopen seems to be ignored below code,if remote host has no responed,the error information:"Error" would not display:

Reproduce code:
$h = fsockopen($server,80,$errno,$errstr,5);
      $str .= fgets($h,127);
   return $str;

Expected result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-05-26 18:40 UTC]
Please try using this CVS snapshot:
For Windows:

I've done a basic test with latest php 5.2 cvs and it works fine. You need to provide more info about your program, like is $server an IP (v4 or v6) or a hostname, the protocol used, etc..
 [2006-05-26 21:12 UTC] brynb at omg-games dot com
I'm having the same problem, even after installing 5.2.
$serverip = "";
$fp = fsockopen($serverip, 80, $errno, $errstr, 3);
	return 0;

//get the response
while (!feof($fp)) $result .= fread($fp,32000);

print $result;

so, the function either times out (30 second script execution limit) or $result ends up as a blank string.  the initial fsockopen call should fail, because i'm contacting an ip at which there's no http server (in fact, it's a 2nd computer sitting RIGHT NEXT TO ME and i'm switching apache on and off to test this thing).  the $serverip variable IS an ipv4 address.  i'm basically sending an http request through tcp (i've even tried prefixing "tcp://" to the ip, with no variance in result).  note that all of this code works perfectly when the apache server is enabled... it's just when it's disabled that i get these results.
 [2006-06-03 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sat Jun 10 03:03:43 2023 UTC