Udp.open/port/send/recv/from_ip/from_port/close/resolve/local_ip/ip/ip_text, native BSD sockets (udp.ll) and Winsock (udp_win.ll, -lws2_32), linked only when a program uses Udp.*; example, docs and tests. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
720 B
720 B
| id | name | category | kind | tokens | sig | tip | order | ns | member |
|---|---|---|---|---|---|---|---|---|---|
| udp-recv | Udp.recv | udp | namespace-method | Udp.recv | Udp.recv(socket, bytes, cap) -> int | Read the next waiting datagram. | 3 | Udp | recv |
Copies the next waiting datagram, up to cap bytes, into bytes and returns its length, or 0 when nothing is waiting. It never blocks: call it in a loop each frame until it returns 0. The sender is Udp.from_ip / from_port.
program Demo {
entry {
let s = Udp.open(port: 0)
let buf = Memory.bytes(64)
print(Udp.recv(socket: s, bytes: buf, cap: 64))
}
}