check return value of bind

is common to forget to run this as root, in which case we would like
to see the permission denied error when it tries to open port 69
This commit is contained in:
Daniel Barlow 2022-10-04 22:02:33 +01:00
parent 71e37f1b96
commit a258456f25

View file

@ -339,7 +339,8 @@ function tftp:listen(rrq_generator_callback, wrq_generator_callback, hosts, port
local logfile = logfile or io.stderr
--listen on all given addresses, default to localhost if not given
for i, address in pairs((type(hosts) == 'table' and hosts) or (hosts ~= nil and{hosts}) or {'127.0.0.1'}) do
socket:bind(address, port)
local ok, err = socket:bind(address, port)
if not ok then error(err .. " binding to " .. address .. ":" .. port) end
end
--[[The main event loop does two things: