1<?php 2$tcp = uv_tcp_init(); 3 4uv_tcp_bind($tcp, uv_ip4_addr('0.0.0.0',9999)); 5 6uv_listen($tcp, 100, function($server){ 7 $client = uv_tcp_init(); 8 uv_accept($server, $client); 9 var_dump(uv_tcp_getsockname($server)); 10 11 uv_read_start($client, function($socket, $buffer) use ($server) { 12 var_dump($buffer); 13 uv_close($socket); 14 uv_close($server); 15 }); 16}); 17 18$c = uv_tcp_init(); 19uv_tcp_connect($c, uv_ip4_addr('0.0.0.0',9999), function($client, $status) { 20 if ($status == 0) { 21 uv_write($client, "Hello", function($socket, $status) { 22 uv_close($socket); 23 }); 24 } 25}); 26 27uv_run(); 28