diff options
author | Christian Pointner <equinox@helsinki.at> | 2011-04-02 17:28:27 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2011-04-02 17:28:27 (GMT) |
commit | 0b45d1f97687ccd7cdcc82fa53530b6dacd6a4b8 (patch) | |
tree | 53f999758f97b2467c83f3ec756e51bce1e96529 | |
parent | 35ba307bec56d265612bdae3114593285fe99381 (diff) |
fixed tcpserver
-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 |