ext-uv/examples/tcp_bind6.php

27 lines
581 B
PHP
Raw Normal View History

2012-06-30 15:15:29 +02:00
<?php
$tcp = uv_tcp_init();
uv_tcp_bind6($tcp, uv_ip6_addr('::1',9999));
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){
2012-06-30 15:15:29 +02:00
echo $buffer;
uv_close($socket);
});
});
$c = uv_tcp_init();
uv_tcp_connect6($c, uv_ip6_addr('::1',9999), function($client, $stat){
2012-06-30 15:15:29 +02:00
if ($stat == 0) {
uv_write($client,"Hello",function($socket, $stat){
2012-06-30 15:15:29 +02:00
uv_close($socket);
});
}
});
uv_run();