-
PHP异步调用socket简单实例
网络 2013/10/2 21:25:02<? $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); ?>
阅读(3000) 分享(0)
上一篇: PHP获取Cookie模拟登录CURL
下一篇: php支持分块与断点续传文件下载功能代码
精彩推荐
◆ 接口限流算法总结