Debian Codegraph @

texk/web2c/luatexdir/luasocket/test/tcp-getoptions

raw
1 #!/usr/bin/env lua
2
3 require"socket"
4
5 port = 8765
6
7 function options(o)
8 print("options for", o)
9
10 for _, opt in ipairs{"keepalive", "reuseaddr", "tcp-nodelay"} do
11 print("getoption", opt, o:getoption(opt))
12 end
13
14 print("getoption", "linger",
15 "on", o:getoption("linger").on,
16 "timeout", o:getoption("linger").timeout)
17 end
18
19 local m = socket.tcp()
20
21 options(m)
22
23 assert(m:bind("*", port))
24 assert(m:listen())
25
26 options(m)
27
28 m:close()
29
30 local m = socket.bind("*", port)
31
32 options(m)
33
34 local c = socket.connect("localhost", port)
35
36 options(c)
37
38 local s = m:accept()
39
40 options(s)
41