aboutsummaryrefslogtreecommitdiff
path: root/test/tcp-getoptions
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xtest/tcp-getoptions28
1 files changed, 22 insertions, 6 deletions
diff --git a/test/tcp-getoptions b/test/tcp-getoptions
index f9b3d1b..fbcc884 100755
--- a/test/tcp-getoptions
+++ b/test/tcp-getoptions
@@ -1,19 +1,35 @@
1#!/usr/bin/env lua 1#!/usr/bin/env lua
2 2
3require"socket" 3local socket = require"socket"
4 4
5port = 8765 5port = 8765
6 6
7function pcalltest(msg, o, opt)
8 local a = { pcall(o.getoption, o, opt) }
9 if a[1] then
10 print(msg, opt, unpack(a))
11 else
12 print(msg, opt, 'fail: ' .. a[2])
13 end
14end
15
7function options(o) 16function options(o)
8 print("options for", o) 17 print("options for", o)
9 18
10 for _, opt in ipairs{"keepalive", "reuseaddr", "tcp-nodelay"} do 19 for _, opt in ipairs{
11 print("getoption", opt, o:getoption(opt)) 20 "keepalive", "reuseaddr",
21 "tcp-nodelay", "tcp-keepidle", "tcp-keepcnt", "tcp-keepintvl"} do
22 pcalltest("getoption", o, opt)
12 end 23 end
13 24
14 print("getoption", "linger", 25 r = o:getoption'linger'
15 "on", o:getoption("linger").on, 26 if r then
16 "timeout", o:getoption("linger").timeout) 27 print("getoption", "linger",
28 "on", r.on,
29 "timeout", r.timeout)
30 else
31 print("getoption", "linger", "no result")
32 end
17end 33end
18 34
19local m = socket.tcp() 35local m = socket.tcp()