make net examples print ip and data

This commit is contained in:
2026-05-20 14:34:31 +02:00
parent 48c58c0709
commit 174dbfa740
3 changed files with 26 additions and 14 deletions

View File

@@ -3,11 +3,17 @@ func main[] : i64
io.println("Listening on port 8000...")
let resp = mem.alloc(60000)
let addr = mem.alloc(16)
while true
let conn = net.accept(s)
let conn = net.accept(s, addr)
if conn < 0
continue
io.printf("%d.%d.%d.%d:%d\n", addr[4], addr[5], addr[6], addr[7], mem.read16be(addr + 2))
io.print_sized(resp, n)
io.println("")
let n = net.read(conn, resp, 60000)
net.send(conn, resp, n)
net.close(conn)