summaryrefslogtreecommitdiff
path: root/tests/modules/socket/tcp/echo_client.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2019-10-27 22:18:03 +0800
committerruki <[email protected]>2019-10-27 22:18:03 +0800
commit444f458546dc9b46a6e3d264f75da31b5bc4431d (patch)
tree39262af5f062db50f1f27d9f00d6013df852af3b /tests/modules/socket/tcp/echo_client.lua
parentfa792567b7df02cf604863589b33405c0c921f54 (diff)
modify tcp echo demo
Diffstat (limited to 'tests/modules/socket/tcp/echo_client.lua')
-rw-r--r--tests/modules/socket/tcp/echo_client.lua13
1 files changed, 11 insertions, 2 deletions
diff --git a/tests/modules/socket/tcp/echo_client.lua b/tests/modules/socket/tcp/echo_client.lua
index 7c88a5992..f3d6d9bae 100644
--- a/tests/modules/socket/tcp/echo_client.lua
+++ b/tests/modules/socket/tcp/echo_client.lua
@@ -6,7 +6,16 @@ function main()
print("connect %s:%d ..", addr, port)
local sock = socket.connect(addr, port)
print("%s: connected!", sock)
- local send = sock:send("hello world..", {block = true})
- print("%s: send %d", sock, send)
+ 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