UDPSocket.onMessage 无法接收消息?
发布于 4 年前 作者 syang 5426 次浏览 来自 官方Issues

UDPSocket.onMessage 在不先调用 UDPSocket.send 无法接受消息

that.udpSocket = wx.createUDPSocket();
that.udpSocket.bind(35675);
that.udpSocket.send({
   address'192.168.1.120',
   port54321,
   message"hello world!"
});
that.udpSocket.onListening(function(res{
   console.log(res);
});
that.udpSocket.onMessage(function(res{
   console.log(res.message);
   console.log(res.remoteInfo.address);
   console.log(res.remoteInfo.port);
   console.log(res.remoteInfo.size);
});
//基础库2.10.2
2 回复

你好,请提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html

我也遇到只能发送信息,UDP接收不到任何信息?

回到顶部