473,379 Members | 1,423 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

Can't get timeout to work with fsockopen

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
2 3785
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
> 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Martin | last post by:
I am a PHP newbie (just got my "Hello World" page working this morning). I'm doing some R&D work to see if PHP is viable for a situation I have. To accomplish what I want to do, I have to have the...
6
by: Captain | last post by:
I'm looking to post data (GET) to a site using a php script - commands like fopen() file_content_gets won't retrieve the data. I assume this is because the server is expecting the request to come...
9
by: fipaj1992 | last post by:
Hi! I have very big problem with fsockopen() function. It is very important... That's code: <?php $test = fsockopen ('chrome.pl', '8080'); ?>
1
by: yawnmoth | last post by:
If fsockopen is used to connect to a computer that's turned off, it takes $timeout seconds. Is there any way to detect whether or not a computer is turned off without taking $timeout seconds?
6
by: murd | last post by:
Hi, I am trying to complete a post using fsockopen but I'm getting the following error: "Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP? I am...
2
by: mydejamail | last post by:
Does the timeout option in the fsockopen command refer to the time allowed for a socket to be made availabe by the OS, or does it refer to the time allowed for reading or writing to the socket once...
1
by: Syl | last post by:
Hi group - I have a database table with 4 columns that hold a url. I am selecting each url and I need to check to see if it is valid. I assumed I could use the fsockopen command. I've had to...
5
by: yawnmoth | last post by:
Say I have the following script: <? $timeout = 5; $start = time(); $fsock = fsockopen('125.1.119.10',80,$errno,$errstr,$timeout); // reduce $timeout by the amount of time that it took for...
8
by: Yoko | last post by:
So I am using php version 4.3.9 and lets say i have a file on the server called tester.php so i am using fsockopen to point to that file but it gives me a error below. $fh =...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.