Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/danog/ipc
Async IPC component for AMPHP
https://github.com/danog/ipc
amphp ipc multiprocessing multithreading
Last synced: 3 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 (almost 5 years ago)
- Default Branch: v1
- Last Pushed: 2023-07-04T14:29:10.000Z (over 1 year ago)
- Last Synced: 2024-09-19T03:19:43.963Z (4 months ago)
- Topics: amphp, ipc, multiprocessing, multithreading
- Language: PHP
- Size: 70.3 KB
- Stars: 4
- Watchers: 3
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# IPC
[![Continuous Integration](https://github.com/danog/ipc/actions/workflows/ci.yml/badge.svg)](https://github.com/danog/ipc/actions/workflows/ci.yml)
![License](https://img.shields.io/badge/license-MIT-blue.svg)`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();
```