diff options
Diffstat (limited to 'mode-tcpserver.lua')
-rw-r--r-- | mode-tcpserver.lua | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/mode-tcpserver.lua b/mode-tcpserver.lua index f1f3e92..671ba09 100644 --- a/mode-tcpserver.lua +++ b/mode-tcpserver.lua @@ -119,7 +119,7 @@ function main_loop(opt) local return_value = 0 while return_value == 0 do - local readable, _, err = socket.select({ sig , cmdfd , server , unpack(clients) }, clients_get_writeables()) + local readable, writeable, err = socket.select({ sig , cmdfd , server , unpack(clients) }, clients_get_writeables()) if(err) then log.printf(log.ERROR, "select returned with error: %s", err) return_value = -1 @@ -149,6 +149,14 @@ function main_loop(opt) end end end + for _, output in ipairs(writeable) do + local ret = output.hdl:send(output.buffer) + if(ret == nil) then + remove_client(output) + else + output.buffer = string.sub(output.buffer, ret+1) + end + end end end |