Event-driven UDP client and server sockets for ReactPHP.
Switch branches/tags
Nothing to show
Clone or download
clue Merge pull request #28 from WyriHaximus-labs/function-name-look-up-pe…

Prefix all global functions calls with \ to skip the look up and resolve process and go straight to the global function
Latest commit 658fe52 Oct 5, 2018



Build Status

Event-driven 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 React\Datagram\Factory($loop);

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

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


See also the examples.


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


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

This project follows SemVer. This will install the latest supported version:

$ composer require react/datagram:^1.4

See also the CHANGELOG for details about version upgrades.

This project aims to run on any platform and thus does not require any PHP extensions and supports running on legacy PHP 5.3 through current PHP 7+ and HHVM. It's highly recommended to use PHP 7+ for this project.


To run the test suite, you first need to clone this repo and then install all dependencies through Composer:

$ composer install

To run the test suite, go to the project root and run:

$ php vendor/bin/phpunit


MIT, see LICENSE file.