adjust fs_poll sample

This commit is contained in:
Shuhei Tanuma 2012-07-15 22:54:56 +09:00
parent ff5f4023f4
commit 157f6ca7e2
2 changed files with 20 additions and 6 deletions

View File

@ -1,8 +1,23 @@
<?php
$poll = uv_poll_init(uv_default_loop(), 0);
uv_poll_start($poll, UV::READABLE | UV::WRITABLE, function($rsc, $stat, $ev, $fd){
uv_close($rsc);
$socket = stream_socket_server("tcp://0.0.0.0:9999", $errno, $errstr);
$poll = uv_poll_init(uv_default_loop(), $socket);
uv_poll_start($poll, UV::READABLE, function($poll, $stat, $ev, $fd) use ($socket){
$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, $fd) use ($conn){
echo "cb";
uv_fs_write(uv_default_loop(), $fd, "echo", -1, function($fs, $fd){
var_dump($fs);
});
uv_fs_close(uv_default_loop(), $fd, function(){
echo "close";
});
});
});
uv_run();
uv_run();

View File

@ -5256,8 +5256,7 @@ PHP_FUNCTION(uv_fs_write)
php_uv_t *uv;
char *buffer;
int buffer_len = 0;
unsigned long fd;
long offset = -1;
long fd, offset = -1;
zend_fcall_info fci = empty_fcall_info;
zend_fcall_info_cache fcc = empty_fcall_info_cache;
php_uv_cb_t *cb;