connection_aborted(), set_time_limit() problem, detecting browser disconnect

From: Date: Fri, 15 Aug 2003 15:19:38 +0000
Subject: connection_aborted(), set_time_limit() problem, detecting browser disconnect
Groups: php.general 
Request: Send a blank email to php-general+get-160321@lists.php.net to get a copy of this message
Im running Apache 1.3 and PHP 4.3. PHP is running as a module in apache, I have code doing something along the following lines set_time_limit( 0 ); while( true ) { // Do something that may take hours to return } What I hoped would happen (as ignore_user_abort is false) would be that when I hit stop on the browser (IE), the PHP module woudl realise the connection was dead and abort my script. This is exactly the behaviour I want, but it dose NOT work. I even tried the following (less than ideal) as a work around. set_time_limit( 0 ); while( connection_aborted() == false ) { Sleep( 1 ); // Do something that takes slightly less time than before } This also dosent work, Im guessing (from the manual) this is due to the fact that connection_aborted only detects the abort when you send something to the browser. As I dont want to send anything this is a problem, this method is also less than idea as i can not sleep for less than 1 second (win32 server). My question is ... Can I make/force PHP to give me the behaviour I want. ie. killing the script the moment the server detects the browser has closed its connection. If this is impossible (I'd be interested to know why) can i make connection_aborted detect the browser closing the connection without sending needless data to the client. Many thanks Rich

« previous php.general (#160321) next »