收藏
回答

微信PC版本支持UDP吗?

微信PC版本,UDP无法连接成功。以下测试代码,在开发者工具及手机上都可以正常执行。在PC版微信里无法发送UDP数据。

   // 测试UDP
    const udp = wx.createUDPSocket()
    console.log("udp:"+udp)
    for (const key in udp) {
      console.log(`${key}${udp[key]}`);
    }
    udp.onError((msg)=>{
      console.log("err msg:"+msg)
    })


  const port= udp.bind()
  console.log("udp port:"+port)
  console.log("udp port:"+typeof(port))
  
  for (const key in port) {
    console.log(`${key}${port[key]}`);
  }


  const keys = Object.keys(port);
  keys.forEach(key => {
    console.log(`${key}${port[key]}`);
  });
 
  udp.send({
    address'47.106.91.154',
    port8888,
    message'hello, how are you'
  })
回答关注问题邀请回答
收藏
登录 后发表内容
问题标签