# UDPSocket.connect(Object object)
相关文档: 网络使用说明、局域网通信
# 功能描述
预先连接到指定的 IP 和 port,需要配合 write 方法一起使用
# 参数
# Object object
属性 | 类型 | 默认值 | 必填 | 说明 |
address | string | 是 | 要发消息的地址 | |
port | number | 是 | 要发送消息的端口号 |
# 示例代码
const udp = tap.createUDPSocket()
udp.bind()
udp.connect({
address: '192.168.193.2',
port: 8848,
})
udp.write({
address: '192.168.193.2',
port: 8848,
message: 'hello, how are you'
})