24 lines
594 B
Plaintext
24 lines
594 B
Plaintext
func main[] : i64
|
|
~s, ok := net.listen(net.pack_addr(127, 0, 0, 1), 8000)
|
|
if !ok
|
|
panic("failed to listen")
|
|
|
|
io.println("Listening on port 8000...")
|
|
|
|
resp := mem.alloc(IP_MAXPACKET)
|
|
addr := _stackalloc(16)
|
|
while true
|
|
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))
|
|
|
|
n := net.read(conn, resp, IP_MAXPACKET)
|
|
|
|
io.print_sized(resp, n)
|
|
io.println("")
|
|
|
|
net.send(conn, resp, n)
|
|
net.close(conn)
|