I am trying to start ReactPHP TCP sockets on a range of TCP ports (1000 to 2000). All the ports are open and I can see the connection established while testing using telnet but the sockets never fires the connection.on('data' ...)
event. Using any kind of port forwarding is not an option.
Everything works while using a smaller port range of exactly 255 socket instead of 1000.
<?php
require 'vendor/autoload.php';
$loop = React\EventLoop\Factory::create();
for ($i = 1000; $i < 2000; $i++) {
$socket[$i] = new React\Socket\Server('127.0.0.1:' . $i, $loop);
$socket[$i]->on('connection', function (React\Socket\ConnectionInterface $connection) {
echo "connection happened";
$connection->write("Hello " . $connection->getRemoteAddress() . "!\n"); // this part works
$connection->on('data', function ($data) use ($connection) {
echo $data; // for some reason this never fires
});
});
}
$loop->run();