文章利用了socket来实现异步调用哦,有需要学习socket的朋友可以参考一下。
<? $host = "www.hzhuti.com"; $path = "/Report.php?ReportID=1"; $cookie = Session_id(); $fp = fsockopen($host, 80, $errno, $errstr, 30); if (!$fp) { print "$errstr ($errno)<br />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); ?>
原文:http://www.php100.com/html/it/focus/2013/0905/5273.html
如需转载请注明: 转载自26点的博客
本文链接地址: socket实现php异步调用
转载请注明:26点的博客 » socket实现php异步调用