well, now you're getting into deep networking land, and probably a bit out of the scope of php's file implementation.
you would probably want to use non-blocking sockets and implement the http transaction yourself. seems that php's socket functions are pretty young at the moment, so it might be safer to write an external program that will accomplish this for you. if you want to stick to php, here's an example someone posted on
the php.net socket_connect() comment section (although the right way to do this would have been to use select() instead of continuous connecting).
PHP Code:
<?
$host = "127.0.0.1";
$port = "80";
$timeout = 15; //timeout in seconds
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP)
or die("Unable to create socket\n");
socket_set_nonblock($socket)
or die("Unable to set nonblock on socket\n");
$time = time();
while (!@socket_connect($socket, $host, $port))
{
$err = socket_last_error($socket);
if ($err == 115 || $err == 114)
{
if ((time() - $time) >= $timeout)
{
socket_close($socket);
die("Connection timed out.\n");
}
sleep(1);
continue;
}
die(socket_strerror($err) . "\n");
}
socket_set_block($this->socket)
or die("Unable to set block on socket\n");
?>