Problematic fsockopen snippet...
Posted: Thu Sep 15, 2005 4:39 am
I am using a PHP script that I did not write which uses this fsockopen snippet to do the workn in "background":
It works, but it does not seem to be reliable enough. I'll gladly replace it with CURL if it solves the reliability problem. Unfortunately, I have very little experience with CURL.
So the questions are:
Do you spot any possible problem with the above fsockopen code that could result in low reliability (I think it has something to do with incorrent connection closing but that could be pure speculation).
Do you know how to accomplish the same thing with CURL?
Thanks!
Tomas
Code: Select all
$op = fsockopen($_SERVER['HTTP_HOST'], 80);
if (!$op) {
echo "$errstr ($errno)<br>\n";
} else {
fputs($op, "GET ". $URL . "\r\n\r\n");
if ($dispoutput) { while (!feof($op)) { echo fread($op, 1024); } }
fclose($op);
}So the questions are:
Do you spot any possible problem with the above fsockopen code that could result in low reliability (I think it has something to do with incorrent connection closing but that could be pure speculation).
Do you know how to accomplish the same thing with CURL?
Thanks!
Tomas