https://github.com/danog/ipc
Async IPC component for AMPHP
https://github.com/danog/ipc
amphp ipc multiprocessing multithreading
Last synced: 2 months ago
JSON representation
Async IPC component for AMPHP
- Host: GitHub
- URL: https://github.com/danog/ipc
- Owner: danog
- License: mit
- Created: 2020-02-14T19:31:34.000Z (about 5 years ago)
- Default Branch: v1
- Last Pushed: 2023-07-04T14:29:10.000Z (almost 2 years ago)
- Last Synced: 2025-02-01T11:11:07.209Z (3 months ago)
- Topics: amphp, ipc, multiprocessing, multithreading
- Language: PHP
- Size: 70.3 KB
- Stars: 7
- Watchers: 3
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# IPC
[](https://github.com/danog/ipc/actions/workflows/ci.yml)
`danog/ipc` provides an async IPC server.
## Installation
```bash
composer require danog/ipc
```## Example
Server:
```php
receive()) {
echo "Received $payload".PHP_EOL;
if ($payload === 'ping') {
$socket->send('pong');
$socket->disconnect();
}
}
echo "Closed connection".PHP_EOL."==========".PHP_EOL;
};$server = listen(sys_get_temp_dir().'/test');
while ($socket = $server->accept()) {
async($clientHandler, $socket);
}
```Client:
```php
receive()) {
echo "Received $payload".PHP_EOL;
}
echo "Closed connection".PHP_EOL;
};$channel = connect(sys_get_temp_dir().'/test');
$thread = async($clientHandler, $channel);
$channel->send('ping');
$thread->await();
```