socket timeout being ignored
- From: "yawnmoth" <terra1024@xxxxxxxxx>
- Date: 2 Aug 2006 01:59:48 -0700
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 fsockopen to
connect.
$timeout-=(time()-$start);
socket_set_timeout($fsock,$timeout);
fputs($fsock,"GET http://www.google.com/ HTTP/1.0\r\n");
fputs($fsock,"Host: www.google.com\r\n\r\n");
while ( !feof($fsock) )
{
echo fgets($fsock);
}
fclose($fsock);
?>
As you can tell, the timeout is set to 5 seconds in fsockopen and then
is set to how ever many seconds out of that 5 that fsockopen didn't
take to connect.
All in all, the whole script should run in, at most, 5 seconds. Or
atleast it seems like it should. Sometimes, however, it doesn't - it
takes several minutes. And unfortunately, this happens enough times to
be kinda a nuisance. And I have no idea what the problem is.
Any ideas?
.
- Follow-Ups:
- Re: socket timeout being ignored
- From: Jerry Stuckle
- Re: socket timeout being ignored
- Prev by Date: Re: Case sensitivity in programming languages.
- Next by Date: fgets not blocking
- Previous by thread: Re: PHP doesn't access root directory using forward slash "/"
- Next by thread: Re: socket timeout being ignored
- Index(es):
Relevant Pages
|