Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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();
```