note 95202 added to function.connection-aborted
| From: | Luciano at osu1 dot php dot net | Date: | Fri, 18 Dec 2009 09:01:07 +0000 |
| Subject: | note 95202 added to function.connection-aborted | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-164101@lists.php.net to get a copy of this message | ||
In order to detect a disconnection inside the script we need to flush the buffer (it is only when
the the server tries to send the buffer content that it will see that the connection is broken).
Thus we need to use the ob_implicit_flush() function to flush automatically the buffer
This is an example of a disconnection detection :
<?php
// enables the automatic flush
ob_implicit_flush();
function verifyCommunication() {
$status = (connection_aborted()?"not ":"") ."sent";
persistCommunication(new Communication($status));
}
// we will check the communication state when the script finished
register_shutdown_function(verifyCommunication);
echo "blabla";
// this sleep is used to have time to break the connection on the client side
sleep(10);
echo"tata";
?>
I use such a process to cancel a request if the client didn't get the acknowledgement because
he will redo his request...
----
Server IP: 194.153.94.10
Probable Submitter: 77.72.128.37
----
Manual Page -- http://www.php.net/manual/en/function.connection-aborted.php
Edit -- https://master.php.net/note/edit/95202
Del: integrated -- https://master.php.net/note/delete/95202/integrated
Del: useless -- https://master.php.net/note/delete/95202/useless
Del: bad code -- https://master.php.net/note/delete/95202/bad+code
Del: spam -- https://master.php.net/note/delete/95202/spam
Del: non-english -- https://master.php.net/note/delete/95202/non-english
Del: in docs -- https://master.php.net/note/delete/95202/in+docs
Del: other reasons-- https://master.php.net/note/delete/95202
Reject -- https://master.php.net/note/reject/95202
Search -- https://master.php.net/manage/user-notes.php