The article uses sockets to implement asynchronous calls. Friends who need to learn sockets can refer to this article and reference materials.
The code is as follows 代码如下 | 复制代码 | $host = "www.hzhuti.com"; $path = "/Report.php?ReportID=1"; $cookie = Session_id(); $fp = fsockopen($host, 80, $errno, $errstr, 30); if (!$fp) { print "$errstr ($errno) n"; exit; } $out = "GET ".$path." HTTP/1.1rn"; $out .= "Host: ".$host."rn"; $out .= "Connection: Closern"; $out .= "Cookie: ".$cookie."rnrn"; fwrite($fp, $out); //将请求写入socket //也可以选择获取server端的响应 /*while (!feof($fp)) { echo fgets($fp, 128); }*/ //如果不等待server端响应直接关闭socket即可 fclose($fp); ?>
| |
Copy code |
$host = "www.hzhuti.com"; $path = "/Report.php?ReportID=1"; $cookie = Session_id() ; $fp = fsockopen($host, 80, $errno, $errstr, 30); if (!$fp) { print "$errstr ($errno ) n"; exit; } $out = "GET ".$path." HTTP/1.1rn"; $out .= "Host: ".$host."rn"; $out .= "Connection: Closern"; $out .= "Cookie: ".$cookie."rnrn"; fwrite($fp, $out); //Write the request to the socket //You can also choose to get the response from the server /*while (!feof($fp)) { echo fgets($fp, 128); }*/ //If you don’t wait for the server-side response, just close the socket directly fclose($fp); ?>
|
For more details about php socket, please refer to
http://www.bkjia.com/phper/30/7cadb3c9195ac7d8ac9104da61a25c6e.htm
http://www.bkjia.com/PHPjc/444704.htmlwww.bkjia.comtrue
http: //www.bkjia.com/PHPjc/444704.htmlThe article uses sockets to implement asynchronous calls. Friends who need to learn sockets can refer to this article and reference materials. oh. The code is as follows Copy the code ? $host = www.hzhuti.com;...