Hi there everyone,
I've got a script that checks for a new version at the parent site. Thanks to help here on the forum previously, this is the code that is used:
if($ver_check == 1) {
$site = 'www.site.com.com';
$address = "/scripts/versions/script_version.php";
$fp = @fsockopen($site, 80, $errno, $errstr, 5);
if ($fp) {
$version = '';
$out = "GET $address HTTP/1.1\r\n";
$out .= "Host: $site\r\n";
$out .= "Connection: Close\r\n\r\n";
fwrite($fp, $out);
while(!feof($fp)) {
$tmp = fgets($fp, 1024);
if(strpos($tmp, 'version:') !== FALSE) {
$version = trim(substr($tmp, 9));
break;
}
}
I'm now expanding the remote connection to retrieve latest news. I'm wondering however if I need to take precautions for the script to be unable to retrieve the data. The version check is at the bottom of the page, so during a stall, it's practically unnoticable, since the page has already loaded. The news will be at the center of the page, however so if it can't contact the parent site, it will stall the page load until PHP feels sufficient time has elapsed(I forget what this time period was).
Is there a way to set the timeout shorter? Something else I can do maybe, or is this just a risk you run when attempting something like this?
Thoughts are appreciated.
thanks,
json