Skip to content

clue-legacy/php-datagram

 
 

Repository files navigation

clue/datagram Build Status

UDP datagram socket client and server for reactphp

Quickstart example

Once installed, you can use the following code to connect to an UDP server listening on localhost:1234 and send and receive UDP datagrams:

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

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

$factory->createClient('localhost:1234')->then(function (Datagram\Socket $client) {
    $client->send('first');

    $client->on('message', function($message, $serverAddress, $client) {
        echo 'received "' . $message . '" from ' . $serverAddress. PHP_EOL;
    });
});

$loop->run();

See also the examples.

Usage

This library's API is modelled after node.js's API for UDP / Datagram Sockets (dgram.Socket).

Install

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

{
    "require": {
        "clue/datagram": "0.5.*"
    }
}

License

MIT

About

[deprecated] UDP client and server sockets for React PHP

Resources

Stars

Watchers

Forks

Packages

No packages published