You've already forked qlg.tsgz.moe
Init Repo
This commit is contained in:
23
vendor/swoole/examples/udp/async_client.php
vendored
Executable file
23
vendor/swoole/examples/udp/async_client.php
vendored
Executable file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
$client = new swoole_client(SWOOLE_SOCK_UDP, SWOOLE_SOCK_ASYNC); //异步非阻塞
|
||||
|
||||
$client->on("connect", function(swoole_client $cli) {
|
||||
echo "connected\n";
|
||||
$cli->send("hello world\n");
|
||||
});
|
||||
|
||||
$client->on('close', function($cli){
|
||||
echo "closed\n";
|
||||
});
|
||||
|
||||
$client->on('error', function($cli){
|
||||
echo "error\n";
|
||||
});
|
||||
|
||||
$client->on("receive", function(swoole_client $cli, $data){
|
||||
echo "received: $data\n";
|
||||
sleep(1);
|
||||
$cli->send("hello_".rand(1000,9999));
|
||||
});
|
||||
|
||||
$client->connect('127.0.0.1', 9502, 0.5);
|
Reference in New Issue
Block a user