concerto / comms
Library for Inter-Process Communications using Unix domain sockets.
This package's canonical repository appears to be gone and the package has been frozen as a result.
Installs: 647
Dependents: 2
Suggesters: 0
Security: 0
Stars: 28
Watchers: 0
Forks: 2
Type:concerto-component
Requires
- php: >=5.4.0
- concerto/sockets: 0.*
- react/event-loop: 0.4.*
- react/socket: 0.4.*
This package is not auto-updated.
Last update: 2020-08-07 18:31:41 UTC
README
Library for Inter-Process Communications using Unix domain sockets.
Install
The recommended way to install Comms is through composer.
{ "require": { "concerto/comms": "0.*" } }
Usage
Server
use Concerto\Comms\Server; use React\EventLoop\Factory; $loop = Factory::create(); $comms = new Server($loop, 'unix://' . __DIR__ . '/test.ipc'); $comms->on('join', function() { echo "Client joined.\n"; }); $comms->on('part', function() { echo "Client exited.\n"; }); $comms->on('message', function($message) use ($comms) { echo "Client said: $message\n"; $comms->send('...'); }); $comms->listen(); $loop->run();
Client
use Concerto\Comms\Client; use React\EventLoop\Factory; $loop = Factory::create(); $comms = new Client($loop, 'unix://' . __DIR__ . '/test.ipc'); $comms->on('join', function() { echo "Server joined.\n"; }); $comms->on('part', function() { echo "Server exited.\n"; exit; }); $comms->on('message', function($data) { echo "Server said: $data\n"; }); $comms->send('...'); $comms->connect(); $loop->run();