This repository has been archived on 2022-12-23. You can view files and clone it, but cannot push or open issues or pull requests.
fuck-premake-old2/binmodules/luasocket/test/tcp-getoptions

42 lines
597 B
Lua

#!/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)