By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,614 Members | 1,653 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,614 IT Pros & Developers. It's quick & easy.

Can't get timeout to work with fsockopen

P: n/a
I'm trying to get a script to timeout if the server is under heavy load or
otherwise unavailable. Eventually, this will try different mirrored domains
as each one times out. But at the moment I can't even get a single domain to
timeout:
$fp = fsockopen("www.example.com", 80, $errno, $errstr, 2);
if(!$fp) {
echo "Unable to open\n";
} else {
fputs($fp, "GET / HTTP/1.0\n\n");
$start = time();
socket_set_timeout($fp, 2);
$res = fread($fp, 20000);
var_dump(stream_get_meta_data($fp));
fclose($fp);
print $res;
}
Is there an override setting in the PHP ini file or something wrong in the
code above?

Thanks in advance

Jul 16 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hi designGuy!

On Wed, 03 Sep 2003 04:48:25 GMT, "DesignGuy" <do********@nowhere.com>
wrote:
I'm trying to get a script to timeout if the server is under heavy load or
otherwise unavailable. Eventually, this will try different mirrored domains
as each one times out. But at the moment I can't even get a single domain to
timeout:
$fp = fsockopen("www.example.com", 80, $errno, $errstr, 2);


(...)

I did something similar quite a while ago and discovered that the
socket functions are full of bugs, which are not solved yet. I had
another contact with them on something else some weeks ago and it
looked the same. Have a look at bugs.php.net yourself.

I don't know how it does it, but maybe you can use

Snoopy on Sourceforge or
curl_* functions

HTH, Jochen
--
Jochen Daum - CANS Ltd.
PHP DB Edit Toolkit -- PHP scripts for building
database editing interfaces.
http://sourceforge.net/projects/phpdbedittk/
Jul 16 '05 #2

P: n/a
> I did something similar quite a while ago and discovered that the
socket functions are full of bugs, which are not solved yet. I had
another contact with them on something else some weeks ago and it
looked the same. Have a look at bugs.php.net yourself.


Hi,

After looking around I got the same impression.... I'll keep looking and
check into your suggestions.

Thanks!

Jul 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.