0

按文档运行了udp服务器:

$serv = new swoole_server("127.0.0.1", 9502, SWOOLE_PROCESS, SWOOLE_SOCK_UDP);
$serv->on('Packet', function ($serv, $data, $clientInfo) {

$serv->sendto($clientInfo['address'], $clientInfo['port'], "Server ".$data);
var_dump($clientInfo);

});
$serv->start();

udp客户端:
$client = new SwooleClient(SWOOLE_SOCK_UDP);
$client->connect('127.0.0.1', 9502, 1);
$i = 'abc';
$client->send($i."n");
$message = $client->recv();
echo "Get Message From Server:{$message}n";

这样是可以接收到客户端发的数据

但是用模拟工具发送udp数据包,服务器接收不到,这有办法解决吗?

2019-05-20 提问
0 个回答

撰写答案

推广链接