feat(udp): Udp.* - polled IPv4 datagrams on macOS and Windows
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>
This commit is contained in:
parent
6a7f1dd393
commit
ebb1a00352
24 changed files with 68630 additions and 66360 deletions
24
docs/language/udp/udp-recv.md
Normal file
24
docs/language/udp/udp-recv.md
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
---
|
||||
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 <code>cap</code> bytes, into <code>bytes</code> and returns its length, or <code>0</code> when nothing is waiting. It never blocks: call it in a loop each frame until it returns <code>0</code>. The sender is <a href="udp-from_ip.html"><code>Udp.from_ip</code></a> / <a href="udp-from_port.html"><code>from_port</code></a>.
|
||||
|
||||
```ludic
|
||||
program Demo {
|
||||
entry {
|
||||
let s = Udp.open(port: 0)
|
||||
let buf = Memory.bytes(64)
|
||||
print(Udp.recv(socket: s, bytes: buf, cap: 64))
|
||||
}
|
||||
}
|
||||
```
|
||||
Loading…
Add table
Add a link
Reference in a new issue