Home Backend Development PHP Tutorial 检测PHP连接状态 必须要发送数据吗

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

Jun 13, 2016 pm 01:45 PM
echo function quot shutdown

求助:检测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掉可以么?

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Two Point Museum: All Exhibits And Where To Find Them
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Can the linux shutdown command shut down immediately? Can the linux shutdown command shut down immediately? Jan 28, 2023 pm 05:26 PM

The Linux shutdown command shutdown can shut down the computer immediately. The root user only needs to execute the "shutdown -h now" command. The shutdown command can be used to perform the shutdown process and send messages to all programs being executed by users before shutting down. The shutdown command requires the system administrator root user to use it.

What does function mean? What does function mean? Aug 04, 2023 am 10:33 AM

Function means function. It is a reusable code block with specific functions. It is one of the basic components of a program. It can accept input parameters, perform specific operations, and return results. Its purpose is to encapsulate a reusable block of code. code to improve code reusability and maintainability.

3 Ways to Set Up Automatic Shutdown in Windows 10/11 3 Ways to Set Up Automatic Shutdown in Windows 10/11 May 01, 2023 pm 10:40 PM

In a busy world, we want to automate things that you want to trigger on a regular basis or in a timely manner. Automation helps control tasks and reduces your effort in performing them. One of these tasks may be to shut down your computer. You may want your computer to shut down regularly, or you may want it to shut down at a specific time of day, or on specific days of the week, or you may want it to shut down all at once. Let's see how to set a timer so that the system shuts down automatically. Method 1: Use the Run dialog box Step 1: Press Win+R, type shutdown-s-t600 and click OK. Note: In the above command, 600 represents the time in seconds. You can change it as needed. It should always be in seconds, not minutes or hours

How to set the scheduled shutdown command in Linux How to set the scheduled shutdown command in Linux Feb 18, 2024 pm 11:55 PM

What is the Linux scheduled shutdown command? When using a Linux system, we often need to schedule a shutdown, such as automatically shutting down after downloading a large number of files, or automatically shutting down the server when it is no longer in use. In Linux systems, scheduled shutdown can be implemented using the "shutdown" command. The "shutdown" command allows the user to shut down or restart the system and set a delay time. By adding parameters to the command, you can implement the scheduled shutdown function. The basic format of the command is as follows: shutdown

MySQL shutdown unexpectedly - How to solve MySQL error: MySQL shut down unexpectedly MySQL shutdown unexpectedly - How to solve MySQL error: MySQL shut down unexpectedly Oct 05, 2023 pm 02:42 PM

MySQL is a commonly used relational database management system that is widely used in various websites and applications. However, you may encounter various problems while using MySQL, one of which is MySQL closing unexpectedly. In this article, we will discuss how to solve MySQL error problems and provide some specific code examples. When MySQL shuts down unexpectedly, we should first check the MySQL error log to understand the reason for the shutdown. Usually, the MySQL error log is located in the MySQL installation directory.

Five selected Go language open source projects to take you to explore the technology world Five selected Go language open source projects to take you to explore the technology world Jan 30, 2024 am 09:08 AM

In today's era of rapid technological development, programming languages ​​are springing up like mushrooms after a rain. One of the languages ​​that has attracted much attention is the Go language, which is loved by many developers for its simplicity, efficiency, concurrency safety and other features. The Go language is known for its strong ecosystem with many excellent open source projects. This article will introduce five selected Go language open source projects and lead readers to explore the world of Go language open source projects. KubernetesKubernetes is an open source container orchestration engine for automated

Go language development essentials: 5 popular framework recommendations Go language development essentials: 5 popular framework recommendations Mar 24, 2024 pm 01:15 PM

"Go Language Development Essentials: 5 Popular Framework Recommendations" As a fast and efficient programming language, Go language is favored by more and more developers. In order to improve development efficiency and optimize code structure, many developers choose to use frameworks to quickly build applications. In the world of Go language, there are many excellent frameworks to choose from. This article will introduce 5 popular Go language frameworks and provide specific code examples to help readers better understand and use these frameworks. 1.GinGin is a lightweight web framework with fast

Implementing distributed task scheduling using Golang's web framework Echo framework Implementing distributed task scheduling using Golang's web framework Echo framework Jun 24, 2023 am 11:49 AM

With the development of the Internet and the advancement of information technology, the era of big data has arrived, and fields such as data analysis and machine learning have also been widely used. In these fields, task scheduling is an inevitable problem. How to achieve efficient task scheduling is crucial to improving efficiency. In this article, we will introduce how to use Golang's web framework Echo framework to implement distributed task scheduling. 1. Introduction to the Echo framework Echo is a high-performance, scalable, lightweight GoWeb framework. It is based on HTTP

See all articles