diff options
| author | ruki <[email protected]> | 2019-12-20 00:53:14 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2019-12-19 23:19:27 +0800 |
| commit | 4ce400a33c26c4d59e76ccb5dc321fe6dabc60f7 (patch) | |
| tree | 7fba42df02bab3ab2702ad57c896002b22cb6518 /tests/modules/socket/unix_tcp/echo_client.lua | |
| parent | db52fd10877391ebc89be2c6551b94901a31e7b6 (diff) | |
add unix socket support
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 |
