diff options
Diffstat (limited to 'tests/modules/socket')
| -rw-r--r-- | tests/modules/socket/unix_tcp/echo_client.lua | 24 | ||||
| -rw-r--r-- | tests/modules/socket/unix_tcp/echo_server.lua | 1 |
2 files changed, 14 insertions, 11 deletions
diff --git a/tests/modules/socket/unix_tcp/echo_client.lua b/tests/modules/socket/unix_tcp/echo_client.lua index 53788d428..27c88cb9f 100644 --- a/tests/modules/socket/unix_tcp/echo_client.lua +++ b/tests/modules/socket/unix_tcp/echo_client.lua @@ -4,17 +4,19 @@ function main(addr) addr = addr or path.join(os.tmpdir(), "echo.socket") print("connect %s ..", addr) local sock = socket.connect_unix(addr) - print("%s: connected!", sock) - local count = 0 - while count < 10000 do - local send = sock:send("hello world..", {block = true}) - if send > 0 then - sock:recv(13, {block = true}) - else - break + if sock then + print("%s: connected!", sock) + local count = 0 + while count < 10000 do + local send = sock:send("hello world..", {block = true}) + if send > 0 then + sock:recv(13, {block = true}) + else + break + end + count = count + 1 end - count = count + 1 + print("%s: send ok, count: %d!", sock, count) + sock:close() end - print("%s: send ok, count: %d!", sock, count) - sock:close() end diff --git a/tests/modules/socket/unix_tcp/echo_server.lua b/tests/modules/socket/unix_tcp/echo_server.lua index 7a2334095..8b69d495f 100644 --- a/tests/modules/socket/unix_tcp/echo_server.lua +++ b/tests/modules/socket/unix_tcp/echo_server.lua @@ -3,6 +3,7 @@ import("core.base.socket") function main(addr) addr = addr or path.join(os.tmpdir(), "echo.socket") + os.tryrm(addr) local sock = socket.bind_unix(addr) sock:listen(20) print("%s: listening %s ..", sock, addr) |
