lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

This code;


local socket = require("socket")
local PORT = 30000

local server1, server2

print (socket._VERSION)
assert(server1:setoption('reuseaddr', true))
assert(server1:bind("*", PORT))

assert(server2:setoption('reuseaddr', true))
assert(server2:bind("*", PORT))


runs fine on Windows, yet on Linux (Debian 7, WM ware image) the second `bind` (for server2) fails with a "socket already in use" error. Despite the 'reuseaddr' socket option.


Anyone seen this and knows how to resolve it?


any help is appreciated.



(testing a server, which involves a lot of tests quickly stopping and starting the server. The abandonned sockets are sometimes not available again before the server restarts, which makes tests fail in an unpredictible manner)