diff options
Diffstat (limited to 'src/main_loop.lua')
-rw-r--r-- | src/main_loop.lua | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/main_loop.lua b/src/main_loop.lua index 9f32d0b..8f69f47 100644 --- a/src/main_loop.lua +++ b/src/main_loop.lua @@ -29,19 +29,22 @@ function main_loop(opt) log.printf("NOTICE", "main_loop started") local sig = signal.init() - local sock = echo_server_init() - if(sock == nil) then return -1 end + local sock = {} + sock[1] = echo_server_init("localhost", 4500) + if(sock[1] == nil) then return -1 end + + sock[2] = echo_server_init("localhost", 10000) + if(sock[2] == nil) then return -1 end local ret = 0 while ret == 0 do - local readable, _, err = socket.select({ sig , sock }, nil) + local readable, _, err = socket.select({ sig , sock[1], sock[2] }, nil) for _, input in ipairs(readable) do if(input == sig) then ret = signal.handle() + if(ret == 1) then break end else - if(input == sock) then - ret = echo_server_recv(sock) - end + ret = echo_server_recv(input) end end end |