Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
How to get php-cgi to detect if you have reset the connection
The following example shows how to correct detect connection status under php-cgi
Works under apache and nginx. Cannot get it to work under lighttpd.
ob_implicit_flush(true); //put these at the beginning
//loop and keep doing something until the user aborts
while (true) {
//keep the following flushes in this order. you must have them in this order to have php
//try to get the connection. I don't know why, but it works.
if(connection_status() != CONNECTION_NORMAL) {
//do something before we die?
} else {
//we have a normal operation still
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment