Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions extension/script/common/net.lua
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,15 @@ function m.listen(protocol, address, port)
fs.remove(address)
end
end
do
-- set SO_REUSEADDR so we can bind again to the same address
-- after a quick restart:
local ok, err = fd:option("reuseaddr", 1)
if not ok then
fd:close()
return nil, err
end
end
do
local ok, err = fd:bind(address, port)
if not ok then
Expand Down
12 changes: 6 additions & 6 deletions extension/script/common/socket.lua
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,12 @@ return function (param)
session:close()
fds[1] = session
elseif t.mode == "listen" then
server:close()
fds[1] = server
if session ~= nil then
session:close()
fds[2] = session
end
fds[1] = server
if session ~= nil then
session:close()
fds[2] = session
end
server:close()
Comment on lines +122 to +127
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do these changes do?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is optional. Just conceptually, clossing the session before shutting down the server.

end
local function is_finish()
for _, fd in ipairs(fds) do
Expand Down
Loading