lev.udp

lev

udp() -> socket, err

Create a non-blocking UDP socket

Returns a wrapped UDP socket that integrates with the event loop. The recvfrom method yields the current coroutine until data arrives, with optional timeout and cancellation support.

bind(addr, 0) binds a port the kernel picks. getsockname returns the bound addr, port, or 0.0.0.0 and 0 on a socket not yet bound. A sendto on an unbound socket binds it.

bind and sendto answer nil, "invalid port" for a port outside 0..65535.