# UDPSocket.send(Object object)
向指定地址发送 UDP 数据。
# 支持情况
| 项 | 说明 |
|---|---|
| 兼容性 | 部分兼容 |
# 语法
udpSocket.send(Object object)
# 参数
Object object
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| address | string | 是 | 目标地址 |
| port | number | 是 | 目标端口 |
| message | string / ArrayBuffer | 是 | 要发送的数据 |
| offset | number | 否 | 数据的偏移量(仅 message 为 ArrayBuffer 时有效) |
| length | number | 否 | 数据的长度(仅 message 为 ArrayBuffer 时有效) |
# 返回值
void。
# 示例代码
udpSocket.send({
address: '192.168.1.100',
port: 8080,
message: new ArrayBuffer(16)
})
# 与微信差异
- 不支持微信的
setBroadcast参数(广播模式)。