diff options
author | Caleb Maclennan <caleb@alerque.com> | 2023-11-10 09:12:04 +0300 |
---|---|---|
committer | Caleb Maclennan <caleb@alerque.com> | 2023-11-10 09:12:04 +0300 |
commit | 5c4fc93d5f4137bf4c22ddf1a048c907a4a26727 (patch) | |
tree | a9a68e1f6a9c3bfe2b64fa1c3a4098865b7d3b5d /test/tcp-getoptions | |
parent | ccef3bc4e2aa6ee5b997a80aabb58f4ff0b0e98f (diff) | |
parent | 43a97b7f0053313b43906371dbdc226271e6c8ab (diff) | |
download | luasocket-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-x | test/tcp-getoptions | 28 |
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 | ||
3 | require"socket" | 3 | local socket = require"socket" |
4 | 4 | ||
5 | port = 8765 | 5 | port = 8765 |
6 | 6 | ||
7 | function 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 | ||
14 | end | ||
15 | |||
7 | function options(o) | 16 | function 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 | ||
17 | end | 33 | end |
18 | 34 | ||
19 | local m = socket.tcp() | 35 | local m = socket.tcp() |