小程序
小游戏
企业微信
微信支付
扫描小程序码分享
UDP通信开发工具与真机调试无法发送数据,预览可以
开发工具可以成功获得端口号 但是调用udp。send函数无法发送数据
2 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
麻烦提供能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
测试后发现接收消息也是有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);
},
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
麻烦提供能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)
测试后发现接收消息也是有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);
},