Baez Posted April 28, 2010 Share Posted April 28, 2010 I have this code to check if a user has disconnected. The loop keeps running, checking for a disconnection and when a user disconnects it should continue to the final function. ignore_user_abort(true); set_time_limit(0); $i = 1; while($i) { echo chr(0); if(connection_aborted()) // check if connection is dead { $i = 0; } sleep(10); // check again in 5 seconds } endScriptFunction(); However this does nothing. The while loop renders all links on the page completely useless and the end script function is never called even if the user closes the page. I've tried echoing a page break instead of null with the same result. Can anyone provide some insight on a better way to do this? Thanks Link to comment https://forums.phpfreaks.com/topic/200054-check-client-connection/ Share on other sites More sharing options...
Ken2k7 Posted April 28, 2010 Share Posted April 28, 2010 Is that the entire script? Link to comment https://forums.phpfreaks.com/topic/200054-check-client-connection/#findComment-1049984 Share on other sites More sharing options...
Baez Posted April 28, 2010 Author Share Posted April 28, 2010 No it isn't. That is only the code at the end of the script. The entire script has classes grabbing code from various places and outputting it to the screen. Link to comment https://forums.phpfreaks.com/topic/200054-check-client-connection/#findComment-1049990 Share on other sites More sharing options...
Ken2k7 Posted April 28, 2010 Share Posted April 28, 2010 Since I can't tell, I'll have to ask. Did you flush the buffer? Link to comment https://forums.phpfreaks.com/topic/200054-check-client-connection/#findComment-1050013 Share on other sites More sharing options...
Baez Posted April 28, 2010 Author Share Posted April 28, 2010 Yes sorry I forgot to add that. I'm using flush() right after the echo chr(0). Link to comment https://forums.phpfreaks.com/topic/200054-check-client-connection/#findComment-1050026 Share on other sites More sharing options...
Ken2k7 Posted April 28, 2010 Share Posted April 28, 2010 ob_implicit_flush Link to comment https://forums.phpfreaks.com/topic/200054-check-client-connection/#findComment-1050035 Share on other sites More sharing options...
Baez Posted April 28, 2010 Author Share Posted April 28, 2010 I'm aware of implicit flushing. Does it make a difference when running this while? Link to comment https://forums.phpfreaks.com/topic/200054-check-client-connection/#findComment-1050040 Share on other sites More sharing options...
Baez Posted April 29, 2010 Author Share Posted April 29, 2010 Still haven't figured out how to get this to work. Any help is great. Link to comment https://forums.phpfreaks.com/topic/200054-check-client-connection/#findComment-1050227 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.