UDP通信开发工具与真机调试无法发送数据,预览可以

发布于 7 年前作者 xiatian11735 次浏览最后编辑 7 年前来自 ask

UDP通信开发工具与真机调试无法发送数据,预览可以

开发工具可以成功获得端口号 但是调用udp。send函数无法发送数据

2 回复
wei05
wei051 楼6 年前

麻烦提供能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html

pingmo
pingmo2 楼5 年前

测试后发现接收消息也是有bug,开发工具同样接收不到消息,不知道这块有没有发送和接收的demo,是不是我代码的问题,代码如下:

login: function () {

console.log(userN);

const udp = wx.createUDPSocket();

const port = udp.bind();

udp.send({

address: '212.xxx.xxx.221',

port: 60105,

message: 'username:' + userN + 'passwd' + passW

})

udp.onListening(function (res) {

console.log(res);

});

udp.onMessage(function (res) {

console.log(res.message);

console.log(res.remoteInfo.address);

console.log(res.remoteInfo.port);

console.log(res.remoteInfo.size);

});

console.log('点击登录');

console.log('username:' + userN + 'passwd' + passW);

},