小程序UDP設置 IP_TTL 套接字選項UDPSocket.setTTL
UDPSocket.setTTL(number ttl)
設置 IP_TTL 套接字選項,用于設置一個 IP 數據包傳輸時允許的最大跳步數
基礎庫 2.18.0 開始支持,低版本需做兼容處理。
小程序插件:支持
參數
number ttl
ttl 參數可以是 0 到 255 之間
示例代碼
const udp = wx.createUDPSocket()
udp.onListening(function () {
udp.setTTL(64)
})
udp.bind()