aruns Posted June 17, 2009 Share Posted June 17, 2009 Hi Guys, Anybody Known about connection_aborted, connection_status, connection_timeout. Where, How, Why these function are use... Thanks Quote Link to comment Share on other sites More sharing options...
Mark Baker Posted June 17, 2009 Share Posted June 17, 2009 They're used if you need to control processing if a user clicks stop while a transaction is being processed, or if a transaction times out. Typically you might set a shutdown function using register_shutdown_function(). If you've set a shutdown handler, then it will be executed whenever a script terminates, eithe rbecause it has completed successfully, because the user has hit abort in his browser, or on a script timeout. Within that shutdown function, you can use connection_aborted(), connection_status() or connection_timeout() to determine why the script has finished, and perform some appropriate action. I log such events using something like: function say_goodbye() { if (connection_aborted()) { $log = fopen('/usr/local/apache/logs/timeout_cli.txt','a'); fwrite($log,gmdate('d M Y H:i:s').' - '.$_SERVER["HOSTNAME"].' --> '.$requestMode.' script for clients '.$requestClass.' at '.$requestMethod.' aborted'."\n"); fclose($log); } elseif (connection_status() == CONNECTION_TIMEOUT) { $log = fopen('/usr/local/apache/logs/timeout_cli.txt','a'); fwrite($log,gmdate('d M Y H:i:s').' - '.$_SERVER["HOSTNAME"].' --> '.$requestMode.' script timeout for clients '.$requestClass.' at '.$requestMethod."\n"); fclose($log); } } register_shutdown_function("say_goodbye"); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.