From 4ce400a33c26c4d59e76ccb5dc321fe6dabc60f7 Mon Sep 17 00:00:00 2001 From: ruki Date: Fri, 20 Dec 2019 00:53:14 +0800 Subject: add unix socket support --- tests/modules/socket/unix_tcp/echo_client.lua | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 tests/modules/socket/unix_tcp/echo_client.lua (limited to 'tests/modules/socket/unix_tcp/echo_client.lua') 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 -- cgit v1.3.1