You are here: Re: socket timeout being ignored « PHP Programming Language « IT news, forums, messages
Re: socket timeout being ignored

Posted by Jerry Stuckle on 08/03/06 20:42

yawnmoth wrote:
> Jerry Stuckle wrote:
>
>>yawnmoth wrote:
>><snip>
>>Could be. I haven't seen that occur, but there could be a bug in it.
>>You could try a big fread() call. Don't know what it will do. I
>>haven't used the timeout parm like that. Normally I want to get the
>>results even if it takes a few second.
>
> I actually would like to get the results, too - just not at the cost of
> a few minutes, heh.
>

In that case I would suggest trying to track down the source of the problem.

If the socket opens OK, you have a connection to the server (what is
this server, anyway - I don't get a response at that IP). It shouldn't
take Google too long to respond since you're not searching. In this
case an IP trace might help.

Another alternative, BTW, to stop processing, would be to check the time
in your loop rather than wait for the timeout. If processing exceeds 5
seconds, stop. For instance:

$timeout = 5;
$start = time();
$fsock = fsockopen('125.1.119.10',80,$errno,$errstr,$timeout);

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) && time() < ($start + $timeout))
{
echo fgets($fsock);
}

fclose($fsock);

This should terminate loop processing as soon as it returns from the
fgets() and you've exceeded you 5 second timeout.

It might allow you to see what you're getting and help track down the
problem.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация