Home >Backend Development >PHP Tutorial >Problems with Socket_Read in PHP_PHP Tutorial
error_reporting(E_ALL);
set_time_limit(0);
$runtimes = 100;
for ($i=0; $ic78ae1393071808678fa96a3e115a927 1)
{
echo ("SOCKET_READ_ERROR: Timeout!!!");
$str = "";
break;
}
$str .= $out;
} while ($out != "");
socket_close($socket);
return $str;
}
/*
function f_socket($website,$url)
{
$fp = fsockopen($website, 80, $errno, $errstr, 30);
if (!$fp)
{
}
else
{
$out = "GET " . $url . " HTTP/1.1 ";
$out .= "Host: " . $website . " ";
$out .= "Connection: Close ";
fwrite($fp, $out);
$str = "";
$start_time = time();
while (!feof($fp))
{
$str .= fread($fp, 8192);
if (time()-$start_time > 1)
{
$str = "";
echo "timeout!!!";
break;
}
}
return $str;
}
}
*/
?>