Skip to content

Instantly share code, notes, and snippets.

@kelunik
Created October 10, 2017 14:23
Show Gist options
  • Save kelunik/79f843c541aceb3927c5463cc643d502 to your computer and use it in GitHub Desktop.
Save kelunik/79f843c541aceb3927c5463cc643d502 to your computer and use it in GitHub Desktop.
<?php
require __DIR__ . "/vendor/autoload.php";
$loop = React\EventLoop\Factory::create();
$server = new React\Socket\Server("127.0.0.1:1337", $loop);
$server->on("connection", function ($client) use ($loop) {
print "New client..." . PHP_EOL;
$client->write("Hello World." . PHP_EOL);
$process = new React\ChildProcess\Process("sleep 10");
$process->start($loop);
$loop->addTimer(1, [$client, "close"]);
});
$loop->run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment