mirror of
https://github.com/danog/ext-uv.git
synced 2024-11-30 04:29:01 +01:00
adjust poll example [ci skip]
This commit is contained in:
parent
01ba787a36
commit
32ea5e154f
@ -1,21 +1,25 @@
|
||||
<?php
|
||||
|
||||
$socket = stream_socket_server("tcp://0.0.0.0:9999", $errno, $errstr);
|
||||
stream_set_blocking($socket, 0);
|
||||
|
||||
$poll = uv_poll_init(uv_default_loop(), $socket);
|
||||
|
||||
uv_poll_start($poll, UV::READABLE, function($poll, $stat, $ev, $socket){
|
||||
echo "parent poll:\n";
|
||||
var_dump($stat);
|
||||
$conn = stream_socket_accept($socket);
|
||||
echo "poll";
|
||||
|
||||
$pp = uv_poll_init(uv_default_loop(), $conn);
|
||||
uv_poll_start($pp, UV::READABLE | UV::WRITABLE, function($poll, $stat, $ev, $conn){
|
||||
uv_poll_start($pp, UV::WRITABLE, function($poll, $stat, $ev, $conn){
|
||||
echo " cb";
|
||||
var_dump($stat);
|
||||
var_dump($conn);
|
||||
|
||||
uv_fs_write(uv_default_loop(), $conn, "echo", -1, function($fs, $conn){
|
||||
var_dump($fs);
|
||||
});
|
||||
|
||||
uv_fs_close(uv_default_loop(), $conn, function(){
|
||||
echo "close";
|
||||
uv_poll_stop($poll);
|
||||
uv_fs_write(uv_default_loop(), $conn, "Hello World", -1, function($conn, $nwrite){
|
||||
var_dump($conn);
|
||||
fclose($conn);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user