Net_Server development
| From: | Stephan Schmidt | Date: | Mon, 01 Sep 2003 13:06:40 +0000 |
| Subject: | Net_Server development | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-20953@lists.php.net to get a copy of this message | ||
Hi,
I'm currently working on my Net_Server class. The next release will include
two classes (three if you count a base class):
- Net_Server_Sequential (i.e. the current implementation)
- Net_Server_Forking (a server class that will fork independent server
processes using pcntl_fork()). Has lesser features (as you do not know about
all childs), but enables you to create servers that deliver large amounts of
data.
Both servers will work with callbacks and can be easily be replaced with
each other, you only have to do some minor adjustments.
Now I've got some kind of deisng questions as there are two possible
approaches.
1. in your application you include Net/Server/Sequential.php or
Net/Server/Forking.php and extend this class. Callbacks have to be
implemented in the new class. This is the way how it is done with Net_Server
0.9, all users of teh old class had to change was the filename of the
include and the classname of the extends.
2. Break BC and instantiate a server with:
$server = &Net_Server::create( "Forking", "localhost", 9090 );
$callbackObj = &new MyCallbackObj();
$server->registerCallbackObject($callbackObj);
$server->start();
Then the call back object only had methods for the callbacks, plus a
$this->_server property (if you want it) that enables you to send data back
to the client (as it gives you full access to the server's functionality).
Personally I'd prefer the second alternative, as I think it's cleaner. But
it breaks BC :-(
@Tomas: I hope you are satisfied that I'm working on a new version, that
provides the features you wanted. It will only work on Linux, but maybe the
threads extension can be used on Windows (not sure what it does and how it
works, I only know it's there)
Stephan