ext-uv/README.md

494 lines
9.6 KiB
Markdown
Raw Normal View History

2012-05-28 18:14:55 +02:00
# php-uv
2012-06-25 06:37:00 +02:00
[![Build Status](https://secure.travis-ci.org/chobie/php-uv.png)](http://travis-ci.org/chobie/php-uv)
2012-07-01 17:51:08 +02:00
interface to libuv for php (experimental). also supports http-parser.
# Experimental
This extension is experimental, its functions may change their names
or move to extension all together so do not rely to much on them you have been warned!
# Install
````
git clone https://github.com/chobie/php-uv.git --recursive
cd php-uv
(cd libuv && make)
phpize
./configure
make
make install
# add `extension=uv.so` to your php.ini
````
# Examples
see examples and tests directory.
````
<?php
$tcp = uv_tcp_init();
uv_tcp_bind($tcp, uv_ip4_addr('0.0.0.0',8888));
uv_listen($tcp,100, function($server){
$client = uv_tcp_init();
uv_accept($server, $client);
var_dump(uv_tcp_getsockname($server));
uv_read_start($client, function($socket, $nread, $buffer){
var_dump($buffer);
uv_close($socket);
});
});
$c = uv_tcp_init();
uv_tcp_connect($c, uv_ip4_addr('0.0.0.0',8888), function($stream, $stat){
if ($stat == 0) {
uv_write($stream,"Hello",function($stream, $stat){
uv_close($stream);
});
}
});
uv_run();
````
# Community
Check out #php-uv on irc.freenode.net.
2012-05-28 18:14:55 +02:00
# Author
* Shuhei Tanuma
# License
2012-07-01 17:51:08 +02:00
PHP License
2012-07-15 11:32:04 +02:00
# Documents
2012-07-15 11:34:30 +02:00
this documents was generated by `examples/docgen.php`.
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_unref(resource $uv_t)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### long uv_last_error([resource $uv_loop])
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### string uv_err_name(long $error_code)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### string uv_strerror(long $error_code)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_update_time(resource $uv_loop)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_ref(resource $uv_handle)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_run([resource $uv_loop])
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_run_once([resource $uv_loop])
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_loop_delete(resource $uv_loop)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### long uv_now(resource $uv_loop)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_tcp_bind(resource $uv_sockaddr)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_tcp_bind6(resource $uv_sockaddr)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_write(resource $handle, string $data, callable $callback)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_write(resource $handle, string $data, callable $callback)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_tcp_nodelay(resource $handle, bool $flag)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_accept(resource $server, resource $client)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_shutdown(resource $handle, callable $callback)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_close(resource $handle, callable $callback)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_read_start(resource $handle, callable $callback)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_read2_start(resource $handle, callable $callback)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_read_stop(resource $handle)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### resource uv_ip4_addr(string $ipv4_addr, long $port)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### resource uv_ip6_addr(string $ipv6_addr, long $port)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_listen(resource $handle, long $backlog, callable $callback)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_tcp_connect(resource $handle, string $ipv4_addr, callable $callback)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_tcp_connect6(resource $handle, string $ipv6_addr, callable $callback)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### resource uv_timer_init([resource $loop])
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_timer_start(resource $timer, long $timeout, long $repeat, callable $callback)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_timer_stop(resource $timer)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_timer_again(resource $timer)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_timer_set_repeat(resource $timer, long $repeat)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### long uv_timer_get_repeat(resource $timer)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_idle_start(resource $idle, callable $callback)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_getaddrinfo(resource $loop, callable $callback, string $node, string $service, array $hints)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_idle_stop(resource $idle)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### resource uv_tcp_init([resource $loop])
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### resource uv_idle_init([resource $loop])
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### resource uv_default_loop()
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### resource uv_loop_new()
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### resource uv_udp_init([resource $loop])
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_udp_bind(resource $resource, resource $address, long $flags)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_udp_bind6(resource $resource, resource $address, long $flags)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_udp_recv_start(resource $handle, callable $callback)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_udp_recv_stop(resource $handle)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### long uv_udp_set_membership(resource $handle, string $multicast_addr, string $interface_addr, long $membership)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_udp_set_multicast_loop(resource $handle, long $enabled)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_udp_set_multicast_ttl(resource $handle, long $ttl)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_udp_set_broadcast(resource $handle, bool $enabled)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_udp_send(resource $handle, string $data, resource $uv_addr, callable $callback)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_udp_send6(resource $handle, string $data, resource $uv_addr6, callable $callback)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### bool uv_is_active(resource $handle)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### bool uv_is_readable(resource $handle)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### bool uv_is_writable(resource $handle)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### bool uv_walk(resource $loop, callable $closure[, array $opaque])
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### resource uv_pipe_init(resource $loop, long $ipc)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_pipe_open(resource $handle, long $pipe)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### long uv_pipe_bind(resource $handle, string $name)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_pipe_connect(resource $handle, string $path, callable $callback)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_pipe_pending_instances(resource $handle, long $count)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### resource uv_ares_init_options(resource $loop, array $options, long $optmask)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void ares_gethostbyname(resource $handle, string $name, long $flag, callable $callback)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### array uv_loadavg(void)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### double uv_uptime(void)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### long uv_get_free_memory(void)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### long uv_get_total_memory(void)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### long uv_hrtime(void)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### string uv_exepath(void)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### string uv_cwd(void)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### array uv_cpu_info(void)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### array uv_interface_addresses(void)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### resource uv_spawn(resource $loop, string $command, array $args, array $context, callable $callback)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_process_kill(resource $handle, long $signal)
2012-07-15 11:32:04 +02:00
TODO:
2012-07-15 11:34:30 +02:00
### void uv_kill(long $pid, long $signal)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### bool uv_chdir(string $directory)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### resource uv_rwlock_init(void)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### uv_rwlock_rdlock(resource $handle)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### bool uv_rwlock_tryrdlock(resource $handle)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_rwlock_rdunlock(resource $handle)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### uv_rwlock_wrlock(resource $handle)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### uv_rwlock_trywrlock(resource $handle)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### uv_rwlock_wrunlock(resource $handle)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### uv_lock uv_mutex_init(void)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_mutex_lock(uv_lock $lock)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### bool uv_mutex_trylock(uv_lock $lock)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### uv_lock uv_sem_init(void)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_sem_post(uv_lock $sem)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_sem_wait(uv_lock $sem)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_sem_trywait(uv_lock $sem)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### resource uv_prepare_init(resource $loop)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_prepare_start(resource $handle, callable $callback)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_prepare_stop(resource $handle)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### resoruce uv_check_init([resource $loop])
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_check_start(resource $handle, callable $callback)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_check_stop(resource $handle)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### resource uv_async_init(resource $loop, callable $callback)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_async_send(resource $handle)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_queue_work(resource $loop, callable $callback, callable $after_callback)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### resource uv_fs_open(resource $loop, string $path, long $flag, long $mode, callable $callback)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_fs_read(resoruce $loop, zval $fd, callable $callback)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_fs_close(resource $loop, zval $fd, callable $callback)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_fs_write(resource $loop, zval $fd, string $buffer, long $offset, callable $callback)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_fs_fsync(resource $loop, zval $fd, callable $callback)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_fs_fdatasync(resource $loop, zval $fd, callable $callback)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_fs_ftruncate(resource $loop, zval $fd, long $offset, callable $callback)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_fs_mkdir(resource $loop, string $path, long $mode, callable $callback)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_fs_rmdir(resource $loop, string $path, callable $callback)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_fs_unlink(resource $loop, string $path, callable $callback)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_fs_rename(resource $loop, string $from, string $to, callable $callback)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_fs_utime(resource $loop, string $path, long $utime, long $atime, callable $callback)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_fs_futime(resource $loop, zval $fd, long $utime, long $atime callable $callback)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_fs_chmod(resource $loop, string $path, long $mode, callable $callback)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_fs_fchmod(resource $loop, zval $fd, long $mode, callable $callback)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_fs_chown(resource $loop, string $path, long $uid, long $gid, callable $callback)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_fs_fchown(resource $loop, zval $fd, long $uid, $long $gid, callable $callback)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_fs_link(resource $loop, string $from, string $to, callable $callback)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_fs_symlink(resource $loop, string $from, string $to, long $flags, callable $callback)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_fs_readlink(resource $loop, string $path, callable $callback)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_fs_stat(resource $loop, string $path, callable $callback)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_fs_lstat(resource $loop, string $path, callable $callback)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_fs_fstat(resource $loop, zval $fd, callable $callback)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### uv_fs_readdir(resource $loop, string $path, long $flags, callable $callback)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_fs_sendfile(resource $loop, zval $in_fd, zval $out_fd, long $offset, long $length, callable $callback)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### resource uv_fs_event_init(resource $loop, string $path, callable $callback, long $flags = 0)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### resource uv_tty_init(resource $loop, zval $fd, long $readable)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### long uv_tty_get_winsize(resource $tty, long &$width, long &$height)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### long uv_tty_set_mode(resource $tty, long $mode)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_tty_reset_mode(void)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### string uv_tcp_getsockname(resource $uv_sockaddr)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### string uv_tcp_getpeername(resource $uv_sockaddr)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### string uv_udp_getsockname(resource $uv_sockaddr)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### long uv_resident_set_memory(void)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### string uv_ip4_name(resource uv_sockaddr $address)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### string uv_ip6_name(resource uv_sockaddr $address)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### uv uv_poll_init([resource $uv_loop], zval fd)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### uv uv_poll_start(resource $handle, $events, $callback)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_poll_stop(resource $poll)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### uv uv_fs_poll_init([resource $uv_loop])
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### uv uv_fs_poll_start(resource $handle, $callback, string $path, long $interval)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### void uv_fs_poll_stop(resource $poll)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### resource uv_http_parser_init(long $target = UV::HTTP_REQUEST)
2012-07-15 11:32:04 +02:00
2012-07-15 11:34:30 +02:00
### bool uv_http_parser_execute(resource $parser, string $body, array &$result)
2012-07-15 11:32:04 +02:00