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));
|
|
|
|
|
2012-07-07 12:23:22 +02:00
|
|
|
uv_read_start($client, function($socket, $nread, $buffer) use ($server){
|
2012-07-10 18:26:37 +02:00
|
|
|
var_dump($buffer);
|
2012-06-30 15:15:29 +02:00
|
|
|
uv_close($socket);
|
2012-07-07 12:23:22 +02:00
|
|
|
uv_close($server);
|
2012-06-30 15:15:29 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
$c = uv_tcp_init();
|
2020-02-15 22:36:03 +01:00
|
|
|
uv_tcp_connect($c, uv_ip6_addr('::1',9999), function($client, $stat){
|
2012-06-30 15:15:29 +02:00
|
|
|
if ($stat == 0) {
|
2012-07-01 15:28:57 +02:00
|
|
|
uv_write($client,"Hello",function($socket, $stat){
|
2012-06-30 15:15:29 +02:00
|
|
|
uv_close($socket);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
uv_run();
|