lunarmodules / luasocket

Network support for the Lua language
http://lunarmodules.github.io/luasocket/
MIT License
1.83k stars 626 forks source link

Using socket.bind as a mutex doesn't work on Windows #402

Open hepiyellow opened 1 year ago

hepiyellow commented 1 year ago

Hi,

I am using socket.bind() to implement a mutex, and protect data from begin accessed by multiple thread at the same time. It works well on Mac, but on Windows 10 I see that multiple threads are binding successfully at the same time (before the first thread closes the socket)

I see that the bind() implementation uses the socket.core's bind() method.

1) Is there a known issue on Windows? 2) Should use the socket.core's bind() directly?

alerque commented 1 year ago

I'm afraid I do not use or even have access to a Windows machine to test this or suggest a fix. There are some Windows users around so hopefully somebody else can chime in.

If it does turn out there is a problem with the library on Windows I'd be happy to facilitate a PR getting merged if somebody in the know contributes a fix.