Support getoption method for tcp objects.
This commit is contained in:
parent
0716cb868e
commit
8bb542baaf
6 changed files with 170 additions and 1 deletions
41
test/tcp-getoptions
Executable file
41
test/tcp-getoptions
Executable file
|
@ -0,0 +1,41 @@
|
|||
#!/usr/bin/env lua
|
||||
|
||||
require"socket"
|
||||
|
||||
port = 8765
|
||||
|
||||
function options(o)
|
||||
print("options for", o)
|
||||
|
||||
for _, opt in ipairs{"keepalive", "reuseaddr", "tcp-nodelay"} do
|
||||
print("getoption", opt, o:getoption(opt))
|
||||
end
|
||||
|
||||
print("getoption", "linger",
|
||||
"on", o:getoption("linger").on,
|
||||
"timeout", o:getoption("linger").timeout)
|
||||
end
|
||||
|
||||
local m = socket.tcp()
|
||||
|
||||
options(m)
|
||||
|
||||
assert(m:bind("*", port))
|
||||
assert(m:listen())
|
||||
|
||||
options(m)
|
||||
|
||||
m:close()
|
||||
|
||||
local m = socket.bind("*", port)
|
||||
|
||||
options(m)
|
||||
|
||||
local c = socket.connect("localhost", port)
|
||||
|
||||
options(c)
|
||||
|
||||
local s = m:accept()
|
||||
|
||||
options(s)
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue