Skip to content

Instantly share code, notes, and snippets.

@Pierozi
Created February 15, 2015 16:54
Show Gist options
  • Save Pierozi/2f258cac9842e36d4ab5 to your computer and use it in GitHub Desktop.
Save Pierozi/2f258cac9842e36d4ab5 to your computer and use it in GitHub Desktop.
Create UDP Server Socket with Hoa library
<?php
include(dirname(__DIR__) . '/vendor/autoload.php');
$server = new Hoa\Socket\Server('udp://0.0.0.0:3655');
$server->connectAndWait();
$server->considerRemoteAddress(true);
do {
$line = bin2hex($server->read(32));
echo '< ', $line, "\n";
$msg = hex2bin($line);
$server->write($msg, strlen($msg));
} while (true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment