I have a collection of urls that I visit with file() command. There may be over 300 to visit.
Some of the sites are either down or take too long to load, so I want to be able to move on to the next one faster than it is doing now.

I get the error message
"failed to open stream: Operation timed out in"

Is there a setting I can change so that this would time out even faster than it is doing now? Now it may be something like 1 minutes and I want it set to maybe 20 seconds or less.

    This?
    $Socket = @fsockopen($host, $port, $error_number, $error, $timeout);

      I'm visiting the site to retrieve the source code of the html document. ANyone know how to set a time limit on this action?

        OK, what I mean is before trying to retrieve the html, first check if the http server is responding because unlike file() the fsockopen function does allow you to specify a timeout.

        If the http server is not responding fast enough then don't bother trying to fetch the html.

        See code examples for fsockopen here:
        http://www.php.net/manual/en/function.fsockopen.php

          Write a Reply...