---
id: udp-recv
name: Udp.recv
category: udp
kind: namespace-method
tokens: Udp.recv
sig: Udp.recv(socket, bytes, cap) -> int
tip: Read the next waiting datagram.
order: 3
ns: Udp
member: 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.
```ludic
program Demo {
entry {
let s = Udp.open(port: 0)
let buf = Memory.bytes(64)
print(Udp.recv(socket: s, bytes: buf, cap: 64))
}
}
```