diff options
Diffstat (limited to 'tests/modules/socket/unix_tcp/echo_client.lua')
| -rw-r--r-- | tests/modules/socket/unix_tcp/echo_client.lua | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/modules/socket/unix_tcp/echo_client.lua b/tests/modules/socket/unix_tcp/echo_client.lua new file mode 100644 index 000000000..53788d428 --- /dev/null +++ b/tests/modules/socket/unix_tcp/echo_client.lua @@ -0,0 +1,20 @@ +import("core.base.socket") + +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 + end + count = count + 1 + end + print("%s: send ok, count: %d!", sock, count) + sock:close() +end |
