lua-users home
lua-l archive

Is there a race condition using socket.select on Win32 ?

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


I'm working my way through writing an application using
the luaSocket library.
I'm using Lua 5.1 and luaSocket 2.0.1, and have compiled
and linked under MinGW - and so far things are working, but
I'm reviewing the code for possible race conditions.
My question has to do with potential race conditions in
the example on page 78 of the original PiL.
 The idea of using socket.select() to wait until something
 interesting happens makes sense, but what happens if the
 socket became readable BETWEEN the original timeout and
 when socket.select() is called?
 To make things more interesting, what if the socket never
 gets another character once socket.select() is called?
 Does socket.select() essentially block forever in this case?
I must add that it's surprising just how much functionality
you can build in just a few lines of Lua!
Cheers, Ralph

AltStyle によって変換されたページ (->オリジナル) /