aboutsummaryrefslogtreecommitdiff
path: root/test/tcp-getoptions
diff options
context:
space:
mode:
authorCaleb Maclennan <caleb@alerque.com>2023-11-10 09:12:04 +0300
committerCaleb Maclennan <caleb@alerque.com>2023-11-10 09:12:04 +0300
commit5c4fc93d5f4137bf4c22ddf1a048c907a4a26727 (patch)
treea9a68e1f6a9c3bfe2b64fa1c3a4098865b7d3b5d /test/tcp-getoptions
parentccef3bc4e2aa6ee5b997a80aabb58f4ff0b0e98f (diff)
parent43a97b7f0053313b43906371dbdc226271e6c8ab (diff)
downloadluasocket-hjelmeland-patch-1.tar.gz
luasocket-hjelmeland-patch-1.tar.bz2
luasocket-hjelmeland-patch-1.zip
Merge branch 'master' into hjelmeland-patch-1hjelmeland-patch-1
Diffstat (limited to 'test/tcp-getoptions')
-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()