mirror of
https://github.com/danog/ext-uv.git
synced 2024-11-26 20:14:47 +01:00
add udp example
This commit is contained in:
parent
de66977451
commit
ed029a78e3
19
examples/udp_bind.php
Normal file
19
examples/udp_bind.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
$udp = uv_udp_init();
|
||||
var_dump($udp);
|
||||
|
||||
uv_udp_bind($udp, '0.0.0.0',10000);
|
||||
|
||||
uv_udp_recv_start($udp,function($buffer,$udp){
|
||||
echo "recv:" . $buffer;
|
||||
|
||||
uv_close($udp);
|
||||
});
|
||||
|
||||
$uv = uv_udp_init();
|
||||
uv_udp_send($uv, "Hello", uv_ip4_addr("0.0.0.0",10000),function($s,$uv){
|
||||
echo "success" . PHP_EOL;
|
||||
uv_close($uv);
|
||||
});
|
||||
|
||||
uv_run();
|
Loading…
Reference in New Issue
Block a user