net.send()
Sends a UDP datagram to an explicit destination.
Signature
net.send(socket, host, port, data)
Parameters
Unconnected UDP socket, destination host and port, text or packed bytes.
Returns
Unsigned bytes sent.
Behavior
Resolves a destination compatible with the socket's address family.
Errors
Wrong socket kind, no suitable address, timeout or send error.
Example
use net
a = net.bind('127.0.0.1', 0, {timeout = 2})
b = net.bind('127.0.0.1', 0, {timeout = 2})
assert(net.send(a, '127.0.0.1', net.local(b).port, 'hi') == 2)
assert(count(read(b).data) == 2)
net.close(a)
net.close(b)