2012-06-02 14:45:43 +02:00
|
|
|
<?php
|
|
|
|
$tcp = uv_tcp_init();
|
|
|
|
|
|
|
|
uv_tcp_bind($tcp, uv_ip4_addr('0.0.0.0',9999));
|
|
|
|
|
|
|
|
uv_listen($tcp,100, function($server){
|
|
|
|
$client = uv_tcp_init();
|
|
|
|
uv_accept($server, $client);
|
2012-06-23 13:27:30 +02:00
|
|
|
var_dump(uv_tcp_getsockname($server));
|
|
|
|
|
2012-07-01 15:28:57 +02:00
|
|
|
uv_read_start($client, function($socket, $nread, $buffer){
|
2012-07-02 16:37:44 +02:00
|
|
|
trigger_error("a", E_USER_ERROR);
|
2012-06-02 14:45:43 +02:00
|
|
|
var_dump($buffer);
|
|
|
|
uv_close($socket);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
$c = uv_tcp_init();
|
2012-07-01 15:28:57 +02:00
|
|
|
uv_tcp_connect($c, uv_ip4_addr('0.0.0.0',9999), function($client, $stat){
|
2012-06-02 14:45:43 +02:00
|
|
|
if ($stat == 0) {
|
2012-07-01 15:28:57 +02:00
|
|
|
uv_write($client,"Hello",function($socket, $stat){
|
2012-06-02 14:45:43 +02:00
|
|
|
uv_close($socket);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
uv_run();
|