2012-07-09 05:24:35 +02:00
|
|
|
<?php
|
|
|
|
|
2012-07-15 15:54:56 +02:00
|
|
|
$socket = stream_socket_server("tcp://0.0.0.0:9999", $errno, $errstr);
|
2012-07-15 17:10:55 +02:00
|
|
|
stream_set_blocking($socket, 0);
|
2012-07-15 15:54:56 +02:00
|
|
|
|
|
|
|
$poll = uv_poll_init(uv_default_loop(), $socket);
|
2012-07-15 17:10:55 +02:00
|
|
|
|
2020-02-15 22:36:03 +01:00
|
|
|
uv_poll_start($poll, UV::READABLE, function($poll, $stat, $ev, $socket) {
|
2012-07-15 17:10:55 +02:00
|
|
|
echo "parent poll:\n";
|
|
|
|
var_dump($stat);
|
2012-07-15 15:54:56 +02:00
|
|
|
$conn = stream_socket_accept($socket);
|
2012-07-15 17:10:55 +02:00
|
|
|
|
2012-07-15 15:54:56 +02:00
|
|
|
$pp = uv_poll_init(uv_default_loop(), $conn);
|
2020-02-15 22:36:03 +01:00
|
|
|
uv_poll_start($pp, UV::WRITABLE, function($poll, $stat, $ev, $conn) {
|
2012-07-15 17:10:55 +02:00
|
|
|
echo " cb";
|
|
|
|
var_dump($stat);
|
|
|
|
var_dump($conn);
|
|
|
|
|
|
|
|
uv_poll_stop($poll);
|
2020-02-15 22:36:03 +01:00
|
|
|
uv_fs_write(uv_default_loop(), $conn, "Hello World", -1, function($conn, $nwrite) {
|
2012-07-15 17:10:55 +02:00
|
|
|
var_dump($conn);
|
|
|
|
fclose($conn);
|
2012-07-15 15:54:56 +02:00
|
|
|
});
|
|
|
|
});
|
2012-07-09 05:24:35 +02:00
|
|
|
});
|
|
|
|
|
2020-02-15 22:36:03 +01:00
|
|
|
uv_run();
|