soma56 Posted August 3, 2010 Share Posted August 3, 2010 I'm curious to know if anyone knows if this is possible. Let's say we have a script that's echoing out something to the user. For example: <?PHP $i = 0; while ($i <= 100){ ob_flush(); flush(); $i++; echo $i; } ?> If the internet connection is dropped from the user, is there any way to auto-reconnect as a means of continuing from where the script left off? Quote Link to comment https://forums.phpfreaks.com/topic/209670-is-there-a-way-to-auto-connect-a-php-script/ Share on other sites More sharing options...
Skewled Posted August 3, 2010 Share Posted August 3, 2010 http://php.net/manual/en/function.mysql-ping.php That should help you with what your looking to do. Quote Link to comment https://forums.phpfreaks.com/topic/209670-is-there-a-way-to-auto-connect-a-php-script/#findComment-1094590 Share on other sites More sharing options...
DWilliams Posted August 3, 2010 Share Posted August 3, 2010 What do you mean "where the script left off"? Most PHP scripts are executed in a fraction of a second and then output is sent to the user. If the user still has their web browser open, they won't lose any form information being transmitted via get or post or anything like that. Perhaps tell us more about what you're trying to accomplish? Most likely you can design your code in a modular fashion so that it will be inherently fault tolerant. Quote Link to comment https://forums.phpfreaks.com/topic/209670-is-there-a-way-to-auto-connect-a-php-script/#findComment-1094595 Share on other sites More sharing options...
DWilliams Posted August 3, 2010 Share Posted August 3, 2010 http://php.net/manual/en/function.mysql-ping.php That should help you with what your looking to do. That just makes sure a connection to the MySQL database stays connected. He's talking about the connection from web server to user not web server to database server Quote Link to comment https://forums.phpfreaks.com/topic/209670-is-there-a-way-to-auto-connect-a-php-script/#findComment-1094596 Share on other sites More sharing options...
soma56 Posted August 3, 2010 Author Share Posted August 3, 2010 That's correct. From the web server to the user. I understand php executes quite quickly, however, what interested in researching is event where scripts may take 5 or 10 minutes - is there away to auto-reconnect the web server to the user in the event of a networking issue - for example - if the internet connection from the user drops briefly. Quote Link to comment https://forums.phpfreaks.com/topic/209670-is-there-a-way-to-auto-connect-a-php-script/#findComment-1094600 Share on other sites More sharing options...
kenrbnsn Posted August 3, 2010 Share Posted August 3, 2010 Scripts that take 5 or 10 minutes to run shouldn't be run from a web browser. They should be run in the background and then the use can see the results. Ken Quote Link to comment https://forums.phpfreaks.com/topic/209670-is-there-a-way-to-auto-connect-a-php-script/#findComment-1094605 Share on other sites More sharing options...
soma56 Posted August 3, 2010 Author Share Posted August 3, 2010 Does this mean what I'm trying to accomplish is not possible then? Quote Link to comment https://forums.phpfreaks.com/topic/209670-is-there-a-way-to-auto-connect-a-php-script/#findComment-1094608 Share on other sites More sharing options...
DWilliams Posted August 3, 2010 Share Posted August 3, 2010 Does this mean what I'm trying to accomplish is not possible then? I don't believe there's any way to do specifically what you're trying to do here. This is one of those problems that needs to be solved by better design rather than more features. Quote Link to comment https://forums.phpfreaks.com/topic/209670-is-there-a-way-to-auto-connect-a-php-script/#findComment-1094611 Share on other sites More sharing options...
PFMaBiSmAd Posted August 3, 2010 Share Posted August 3, 2010 It's not actually the web server that makes the connection. It is the other way around, the client connects to the server. The server just uses the existing connection that was made by the client. The connection is kept alive for an amount of inactivity time that is specified either in the Windows registry (IE) or in the browser settings. If the client does drop the connection, there's nothing the server can do about it. Since the web server doesn't have the ability to set the keep alive/inactivity time out, you should not plan on trying to make a connection work this way. Quote Link to comment https://forums.phpfreaks.com/topic/209670-is-there-a-way-to-auto-connect-a-php-script/#findComment-1094618 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.