I have a script that incorporates content from an external site
($rootdomain). During peak traffic periods the external site experiences
severe slowdowns, thereby slowing down the site here. The external site does
have some secondary mirrors, which I would like to revert to if the primary
does not respond, say within 2 or 3 seconds.

Here's the bit of the script that does the connection:

$fp = fopen( $rooturl, "r" );
$html = join( "", file( $rooturl ) );
fclose ( $fp );

Any ideas?