clue/socket-react

Binding for raw sockets (ext-sockets) in reactphp

Maintainers

👁 clue

Package info

github.com/clue/php-socket-react

pkg:composer/clue/socket-react

Statistics

Installs: 1 549

Dependents: 2

Suggesters: 0

Stars: 21

Open Issues: 5

v0.3.0 2014-10-25 09:23 UTC

Requires

Requires (Dev)

None

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT e2f13d6e49e3417d037d6793d0e06b4747a884e5

  • Christian Lück <christian.woop@lueck.tv>

socketsasyncreactlow-levelext-sockets

This package is auto-updated.

Last update: 2026-06-06 11:37:11 UTC


README

Binding for raw sockets (ext-sockets) in React PHP.

Quickstart example

Once installed, you can use the following example to send UDP broadcast datagrams:

$loop = React\EventLoop\Factory::create();

$factory = new Socket\React\Datagram\Factory($loop);

$promise = $factory->createClient('udp://localhost:1337', array('broadcast' => true));
$promise->then(function (Socket\React\Datagram\Socket $socket) {
 $socket->send('test');

 $socket->on('message', function($data, $peer) {
 var_dump('Received', $data, 'from', $peer);
 });
});

$loop->run();

See also the examples.

Install

The recommended way to install this library is through composer. New to composer?

{
 "require": {
 "clue/socket-react": "~0.3.0"
 }
}

Tests

To run the test suite, you need PHPUnit. Go to the project root and run:

$ phpunit tests

Note: The test suite contains tests for ICMP sockets which require root access on unix/linux systems. Therefor some tests will be skipped unless you run sudo phpunit tests to execte the full test suite.

License

MIT