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
|
|
|
|
2012-07-15 16:47:49 +02: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);
|
2012-07-15 17:10:55 +02:00
|
|
|
uv_poll_start($pp, UV::WRITABLE, function($poll, $stat, $ev, $conn){
|
|
|
|
echo " cb";
|
|
|
|
var_dump($stat);
|
|
|
|
var_dump($conn);
|
|
|
|
|
|
|
|
uv_poll_stop($poll);
|
|
|
|
uv_fs_write(uv_default_loop(), $conn, "Hello World", -1, function($conn, $nwrite){
|
|
|
|
var_dump($conn);
|
|
|
|
fclose($conn);
|
2012-07-15 15:54:56 +02:00
|
|
|
});
|
|
|
|
});
|
2012-07-09 05:24:35 +02:00
|
|
|
});
|
|
|
|
|
2012-07-15 15:54:56 +02:00
|
|
|
uv_run();
|