-
Notifications
You must be signed in to change notification settings - Fork 24
Open
Labels
Description
LuaSocket has an intermediate buffer for incoming data. When one calls conn:read(n), n bytes of data will be returned from this buffer, which is refilled from the underlying socket in 8k blocks (BUF_SIZE in buffer.h).
My guess is that this is to reduce the number of syscalls
However, because LuaEvent isn't aware of this buffer, this has the unfortunate side-effect that if you read less than BUF_SIZE, there may still be data left and no new read event will fire until new data comes in from the network.
A workaround is to always read everything, eg by :read()-ing "*a" or BUF_SIZE bytes.