port number.
Returns: `uv_udp_send_t userdata` or `fail`
uv.udp_try_send({udp}, {data}, {host}, {port}) *uv.udp_try_send()*
> method form `udp:try_send(data, host, port)`
Parameters:
- `udp`: `uv_udp_t userdata`
- `data`: `buffer`
- `host`: `string`
- `port`: `integer`
Same as |uv.udp_send()|, but won't queue a send request if it
can't be completed immediately.
Returns: `integer` or `fail`
uv.udp_try_send2({udp}, {messages}, {flags}) *uv.udp_try_send2()*
> method form `udp:try_send2(messages, flags)`
Parameters:
- `udp`: `uv_udp_t userdata`
- `messages`: `table`
- `[1, 2, 3, ..., n]` : `table`
- `data` : `buffer`
- `addr` : `table`
- `ip` : `string`
- `port` : `integer`
- `flags`: `nil` (see below)
- `port`: `integer`
Like `uv.udp_try_send()`, but can send multiple datagrams.
Lightweight abstraction around `sendmmsg(2)`, with a
`sendmsg(2)` fallback loop for platforms that do not support
the former. The `udp` handle must be fully initialized, either
from a `uv.udp_bind` call, another call that will bind
automatically (`udp_send`, `udp_try_send`, etc), or from
`uv.udp_connect`. `messages` should be an array-like table,
where `addr` must be specified if the `udp` has not been
connected via `udp_connect`. Otherwise, `addr` must be `nil`.
`flags` is reserved for future extension and must currently be
`nil` or `0` or `{}`.
Returns the number of messages sent successfully. An error will only be returned
if the first datagram failed to be sent.
Returns: `integer` or `fail`
>lua
-- If client:connect(...) was not called
local addr = { ip = "127.0.0.1", port = 1234 }
client:try_send2({
{ data = "Message 1", addr = addr },
{ data = "Message 2", addr = addr },
})
-- If client:connect(...) was called
client:try_send2({
{ data = "Message 1" },
{ data = "Message 2" },
})
<
uv.udp_recv_start({udp}, {callback}) *uv.udp_recv_start()*
> method form `udp:recv_start(callback)`
Parameters:
- `udp`: `uv_udp_t userdata`
- `callback`: `callable`
- `err`: `nil` or `string`
- `data`: `string` or `nil`
- `addr`: `table` or `nil`
- `ip`: `string`
- `port`: `integer`
- `family`: `string`
- `flags`: `table`
- `partial`: `boolean` or `nil`
- `mmsg_chunk`: `boolean` or `nil`
Prepare for receiving data. If the socket has not previously
been bound with |uv.udp_bind()| it is bound to `0.0.0.0` (the
"all interfaces" IPv4 address) and a random port number.
See |luv-constants| for supported address `family` output values.
Returns: `0` or `fail`
uv.udp_recv_stop({udp}) *uv.udp_recv_stop()*
> method form `udp:recv_stop()`
Parameters:
- `udp`: `uv_udp_t userdata`
Stop listening for incoming datagrams.
Returns: `0` or `fail`
uv.udp_connect({udp}, {host}, {port})