Skip to content

Event-driven UDP client and server sockets for ReactPHP.

License

Notifications You must be signed in to change notification settings

kungvwow/datagram

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Datagram component

Build Status Code Climate

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->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?

$ composer require react/datagram:^1.2

See also the CHANGELOG for details about version upgrades.

Tests

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

License

MIT

About

Event-driven UDP client and server sockets for ReactPHP.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%