aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rwxr-xr-xtest/tcp-getoptions41
1 files changed, 41 insertions, 0 deletions
diff --git a/test/tcp-getoptions b/test/tcp-getoptions
new file mode 100755
index 0000000..f9b3d1b
--- /dev/null
+++ b/test/tcp-getoptions
@@ -0,0 +1,41 @@
1#!/usr/bin/env lua
2
3require"socket"
4
5port = 8765
6
7function 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)
17end
18
19local m = socket.tcp()
20
21options(m)
22
23assert(m:bind("*", port))
24assert(m:listen())
25
26options(m)
27
28m:close()
29
30local m = socket.bind("*", port)
31
32options(m)
33
34local c = socket.connect("localhost", port)
35
36options(c)
37
38local s = m:accept()
39
40options(s)
41