stopping php & keeping php alive

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dan99

    stopping php & keeping php alive

    Hi,

    First of all, I am looking for a way to force the execution of a php
    script to explicitly stop when told to do so by the client
    connection. I know when you hit the browser stop button php normally
    stops, but it doesn't stop immediately (ie. if the script is in a
    loop, it will keep going for a bit). Also, I am looking for a way to
    force php to stay alive, even if the connection to the client drops.
    Finally, does anyone know of a way to enable chatter between a single
    php script and its client (ie. php well send out something, then the
    client will respond, and then php will send another something, ...)

    Thanks,
    Daniel
  • ZeldorBlat

    #2
    Re: stopping php & keeping php alive

    On Feb 14, 9:36 am, Dan99 <power...@gmail .comwrote:
    Hi,
    >
    First of all, I am looking for a way to force the execution of a php
    script to explicitly stop when told to do so by the client
    connection. I know when you hit the browser stop button php normally
    stops, but it doesn't stop immediately (ie. if the script is in a
    loop, it will keep going for a bit). Also, I am looking for a way to
    force php to stay alive, even if the connection to the client drops.
    Finally, does anyone know of a way to enable chatter between a single
    php script and its client (ie. php well send out something, then the
    client will respond, and then php will send another something, ...)
    >
    Thanks,
    Daniel
    Use ignore_user_abo rt():

    <http://www.php.net/ignore_user_abo rt>

    That will definitely answer your second question. I'm not sure if
    there's much you can do about the first one, though. You might try
    checking inside the loop if the connection has been aborted and then
    breaking out of it.

    Comment

    • Rik Wasmus

      #3
      Re: stopping php &amp; keeping php alive

      On Thu, 14 Feb 2008 16:20:50 +0100, ZeldorBlat <zeldorblat@gma il.com>
      wrote:
      On Feb 14, 9:36 am, Dan99 <power...@gmail .comwrote:
      >Hi,
      >>
      >First of all, I am looking for a way to force the execution of a php
      >script to explicitly stop when told to do so by the client
      >connection. I know when you hit the browser stop button php normally
      >stops, but it doesn't stop immediately (ie. if the script is in a
      >loop, it will keep going for a bit). Also, I am looking for a way to
      >force php to stay alive, even if the connection to the client drops.
      >Finally, does anyone know of a way to enable chatter between a single
      >php script and its client (ie. php well send out something, then the
      >client will respond, and then php will send another something, ...)
      >>
      >Thanks,
      >Daniel
      >
      Use ignore_user_abo rt():
      >
      <http://www.php.net/ignore_user_abo rt>
      >
      That will definitely answer your second question. I'm not sure if
      there's much you can do about the first one, though. You might try
      checking inside the loop if the connection has been aborted and then
      breaking out of it.
      In a HTML context, spaces are no content, and if you have no buffering
      mechanism somewhere, a simple statement like this in every loop:
      echo ' ';
      flush();
      if(connection_a borted()) exit;

      ....could very well halt execution sooner. However, if you need to stop
      'dead on', HTTP is not the way to go.
      --
      Rik Wasmus

      Comment

      Working...