qxsch/multi-process-server
Composer 安装命令:
composer require qxsch/multi-process-server
包简介
Runs a multi threaded server.
关键字:
README 文档
README
A multithreaded server for PHP
The TCPServer class provides a very simple interface to communicate with a client. You can control how many processes should be allowed to run concurrently. The TCPServer can be fully observed.
The TCPClient class provides a very simple interface to communicate with a server.
You can send any data between the client and the server that can be serialized.
TLS Encryption with server and client certificate is supported (mutual authentication).
A simple example
Server Code:
<?php $server = new \QXS\MultiProcessServer\TCPServer(12345); // setup the server for 127.0.0.1 on port 12345 // UNCOMMENT THE NEXT LINE TO ADD IMPERSONATION //$server->runAsUser("nobody"); $server->attach(new \QXS\MultiProcessServer\Observers\EchoObserver()); $server->create(new \QXS\MultiProcessServer\ClosureServerWorker( /** * @param \QXS\MultiProcessServer\SimpleSocket $serverSocket the socket to communicate with the client */ function(\QXS\MultiProcessServer\SimpleSocket $serverSocket) { // receive data and send it back $data=$serverSocket->receive(); echo "$data\n"; $serverSocket->send($data); } ));
Client Code:
<?php $client = new \QXS\MultiProcessServer\TCPClient(12345); // connect to 127.0.0.1 on port 12345 $client->send("hi"); echo $client->receive() ."\n";
统计信息
- 总下载量: 68
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0
- 更新时间: 2014-10-19