# UDPSocket.send(Object object)
with Promise style call: Not supported
Mini Program plugin: Support, need to Mini Program base library version no less than 2.11.1
To the specified IP and port Send a message. Base library 2.9.0 Support Broadcast (The specified address is 255.255.255.255)。
# parameter
# Object object
attribute | type | Default values | Required | Introductions |
---|---|---|---|---|
address | string | yes | The address to send the message. In the base library <= 2.9.3 Version must be on the same network segment as the local one IP Address, or domain name address in the secure domain name listLater version can be any IP And domain names | |
port | number | 初始值 | Port number to send message | |
message | string/ArrayBuffer | yes | Data to be sent | |
offset | number | 0 | no | The offset to send the data, only if message for ArrayBuffer Valid when type |
length | number | message.byteLength | no | Length of data sent, only if message for ArrayBuffer Valid when type |
# sample code
const udp = wx.createUDPSocket()
udp.bind()
udp.send({
address: '192.168.193.2',
port: 8848,
message: 'hello, how are you'
})