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>
25 lines
609 B
Markdown
25 lines
609 B
Markdown
---
|
|
id: udp-send
|
|
name: Udp.send
|
|
category: udp
|
|
kind: namespace-method
|
|
tokens: Udp.send
|
|
sig: Udp.send(socket, ip, port, bytes, len) -> int
|
|
tip: Send one datagram.
|
|
order: 2
|
|
ns: Udp
|
|
member: send
|
|
---
|
|
|
|
Sends the first <code>len</code> bytes of <code>bytes</code> to <code>ip</code>:<code>port</code> as one datagram and returns the number of bytes sent, or <code>-1</code>.
|
|
|
|
```ludic
|
|
program Demo {
|
|
entry {
|
|
let s = Udp.open(port: 0)
|
|
let buf = Memory.bytes(4)
|
|
Memory.poke(buf, 0, 1)
|
|
print(Udp.send(socket: s, ip: Udp.ip(text: "127.0.0.1"), port: Udp.port(socket: s), bytes: buf, len: 1))
|
|
}
|
|
}
|
|
```
|