IOS使用UDPSocket.send()报错?
按钮触发这段代码 UDPSocket.send() 报错 onError: send: fail sendUDPSocketMessage:fail function cannot run on service 同时UDPSocket.bind()没有返回port const udpClient = wx.createUDPSocket();
const udpPort = udpClient.bind();
console.log("udp client port: " + udpPort); // 这里输出是: undefined
udpClient.onListening((res) => {
console.log("onListening: ")
console.log(res)
});
udpClient.send({
address: '255.255.255.255',
port: 8266,
message: data
});
udpClient.onError((err) => {
console.log("onError: ")
console.log(err) // send: fail sendUDPSocketMessage:fail function cannot run on service
});
udpClient.onMessage((res) => {
console.log("onMessage: ")
console.log(res)
udpClient.close()
});