Skip to content

Outbound UDP

No FFI is required. Requests use a background worker and never wait for a network reply on the callback thread. Only outbound UDP is provided.

API Result
aqua.udp.send(ip, port, data) Request ID when queued, or nil, reason
aqua.udp.poll(id) Consumes {ok, bytes, error} when ready; otherwise nil, "pending" or nil, "unknown request"
aqua.udp.cancel(id) Removes this script’s request/result; true if it existed

ip must be a numeric IPv4 or IPv6 address, such as "127.0.0.1" or "::1"; hostnames and address-with-port strings are not accepted. port is an integer from 1 to 65535. data is a binary string, including embedded NUL, with at most 1200 bytes. An empty string sends a zero-length datagram.

There are 8 outstanding requests/results per script, 32 overall, and a rate limit of 32 sends per second per script with burst 8. Poll completed requests to free their slots. Unconsumed work/results expire after 30 seconds. Request IDs belong to the publishing script; another script cannot poll or cancel them.

ok=true means the local socket accepted the datagram, not that the recipient received it. UDP supplies no acknowledgements, ordering or retransmission. Socket errors appear in the completed result. Cancel/stop/error/unload removes queued work and results; a datagram already being sent may still reach its recipient.

local request, reason = aqua.udp.send("127.0.0.1", 40123, "hello")
function on_draw()
if not request then return end
local result, state = aqua.udp.poll(request)
if result then
if not result.ok then print(result.error) end
request = nil
elseif state ~= "pending" then
request = nil
end
end