Hi,
This is the final script I have come up with
function Read_Page($Source_Page_Code, $Base_Source_URL)
{
global $Bytes, $Soc_Open_Secs, $Soc_Read_Secs;
$Data_URL = $Base_Source_URL[Start] . $Source_Page_Code;
echo 'Data URL =' . $Data_URL . "<br>\n";
$fp = fsockopen($Data_URL, $Soc_Open_Secs); //open connection
if(!$fp)
{
Error_Message("Socket did not open in $Soc_Open_Secs Seconds");
}
else
{
fputs($fp, "GET / HTTP/1.0\n\n"); //send HTTP request
socket_set_timeout($fp, $Soc_Read_Secs);
while (!feof($fp))
{
$Page_Data .= fread($fp, $Bytes[Team_Page]); //read page contents
}
fclose($fp);
}
if($Page_Data)
{
//echo "This is Page_Data = $Page_Data \n<br>"; #############****************************************
return $Page_Data;
}
}
However, when I set $Soc_Read_Secs to x number of seconds (eg 10 secs), it throws up the error almost instantly i.e from my understanding it is not waiting for the 10 seconds to elapse. Is this a problem with my script or is it a bug in PHP ?
If it is a bug, then does anyone know a simple work around where I can make a script to do what I want : Try to read data from a page via http in 'x' seconds - if no data has been read in that time the script simply moves onto the next URL to read (rather than hanging until it timeouts or eventually reads the data after a very long time).
Many thanks for the help.