I'm trying to create a Asynchronous socket server to handle socket client, send message to client when it's needs. I use reactphp library to implement it but I can't do correct, my server still is blocked. I'm new in this library, please help.
require 'vendor/autoload.php';
$loop = React\EventLoop\Factory::create();
$socket = new React\Socket\Server($loop);
$socket->on('connection', function ($conn) {
$conn->pipe($conn);
});
echo "Socket server listening on port 4000.
";
echo "You can connect to it by running: telnet localhost 4000
";
$socket->listen(4200);
$loop->run();
// code bottom doesn't run because of blocking socket