PHP code example of clue / socket-react
1. Go to this page and download the library: Download clue/socket-react library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
clue / socket-react example snippets
$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();