Skip to content

Commit a74815c

Browse files
committed
add listen(...):sock() method
access underlying luasocket
1 parent 9ade24f commit a74815c

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

spec/server_ev_spec.lua

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,19 @@ describe(
3131
s:close()
3232
end)
3333

34+
it(
35+
's:sock() provides access to the listening socket',
36+
function()
37+
local s = server.ev.listen
38+
{
39+
default = function() end,
40+
port = port
41+
}
42+
assert.is_truthy(tostring(s:sock()):match('tcp'))
43+
s:close()
44+
end)
45+
46+
3447
it(
3548
'call listen with protocol handlers',
3649
function()

src/websocket/server_ev.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,11 @@ local listen = function(opts)
166166
error(err)
167167
end
168168
listener:settimeout(0)
169+
170+
self.sock = function()
171+
return listener
172+
end
173+
169174
local listen_io = ev.IO.new(
170175
function()
171176
local client_sock = listener:accept()

0 commit comments

Comments
 (0)