Jump to content

Recommended Posts

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?

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.

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

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.

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.

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.