php 异步请求文件,实现多线程
程序员文章站
2024-01-31 09:30:16
...
php 异步请求文件,实现多线程源码
$content='';
$fp = fsockopen("www.php100.com", 80, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)
\n";
} else {
$out = "POST /test.php?id=5".$content." HTTP/1.1\r\n";
$out .= "Host:www.php100.com\r\n";
$out .= "Content-Length: ". strlen($content) ."\r\n";
$out .= "Connection: Close\r\n\r\n";
$out .= $content;
$out .= "\r\n\r\n";
fwrite($fp, $out);
/*//忽略执行结果
while (!feof($fp)) {
echo fgets($fp, strlen($content));
} */
echo 'zhinxging';
fclose($fp);
}
$content='';
$fp = fsockopen("www.php100.com", 80, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)
\n";
} else {
$out = "POST /test.php?id=5".$content." HTTP/1.1\r\n";
$out .= "Host:www.php100.com\r\n";
$out .= "Content-Length: ". strlen($content) ."\r\n";
$out .= "Connection: Close\r\n\r\n";
$out .= $content;
$out .= "\r\n\r\n";
fwrite($fp, $out);
/*//忽略执行结果
while (!feof($fp)) {
echo fgets($fp, strlen($content));
} */
echo 'zhinxging';
fclose($fp);
}