检测PHP连接状态 必须要发送数据吗

WBOY
Release: 2016-06-13 10:05:01
Original
1009 people have browsed it

求助:检测PHP连接状态 必须要发送数据吗?
我有个应用,客户提交计算后服务器开始计算,等待1分钟左右,返回计算结果,中途客户端退出我这需要退出计算

问题1:如何在不发送字节的前提下检测状态,例如下面是发送字节检测连接状态的代码

function sd()
{
if(connection_status()!=0)
file_put_contents("D:\\AppServ\\www\\提前退出.txt", "");
}
register_shutdown_function("sd");

for($i=0; $i{
echo "1";
flush();
sleep(1);
}
echo "END";
?>
这代码在客户端关闭请求时会触发建立txt文件,可是我想把echo "1"去掉,或者发送个0字节的东西,我试了多种方法都不行



问题2:proc_open打开的程序如何在shutdown回调中强行杀死

------解决方案--------------------
1、php 只在输出时检查连接状态。你可以只输出空格
2、如果没用预置通讯接口,则不可能做到
------解决方案--------------------
proc_get_status获取进程id再kill掉可以么?

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!