Re: Can a PHP 5 Object Be Persisted Past Script End?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, August 18, 2006 11:39 am, Bruce Bailey wrote:
> Interesting.  Could you expand a little bit about what you mean by
> 'message
> / distribution handler'?  My PHP isn't terribly good -- just enough to
> write
> test scripts for C/C++ extensions for others to use.

<?php
  $socket = socket_create(...);
  socket_bind($socket, ...);
  while (true) { //loop forever, getting input
    $data = socket_listen($socket, ...);
    $parts = explode(",", $data);
    $destination = $parts[0];
    switch ($destination){
      //Hand off message for $destination to another process/script to
do something
      //This is kind of how Apache works...

      //Or maybe just deal with $data here, and then sit back and
listen for more stuff to do
      //This is kind of how MySQL server works
    }
  }
?>

The trick is in finding a suitable way to break down the requests
quickly and efficiently, and either deal with them super fast or route
them to somebody else to deal with so that main loop that runs forever
can always be sucking data in as fast as it comes, and getting it out
of the main loop being a CPU hog.

You don't want to fork in a web environment, almost for sure, but if
you can break down the tasks by a good taxonomy where any given task
can be dealt with WITHOUT needing to look up anything from other
tasks, you've won the battle.  This is why HTTP is the way it is.

If you can make your object data "live" in that main script above, it
will just be there all the time...

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux