summaryrefslogtreecommitdiff
path: root/tests/modules/socket/tcp/echo_client.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2020-08-04 22:45:20 +0800
committerruki <[email protected]>2020-08-04 22:45:20 +0800
commit81c072eaa6eadde5f6427e0109226a7fa04691b0 (patch)
tree7243963c4614209145b441144093889fface5102 /tests/modules/socket/tcp/echo_client.lua
parent8b08fbb9f5f0f54dd1232f4bf387932116dde47f (diff)
improve pushpointer
Diffstat (limited to 'tests/modules/socket/tcp/echo_client.lua')
-rw-r--r--tests/modules/socket/tcp/echo_client.lua24
1 files changed, 13 insertions, 11 deletions
diff --git a/tests/modules/socket/tcp/echo_client.lua b/tests/modules/socket/tcp/echo_client.lua
index f3d6d9bae..6c7d67068 100644
--- a/tests/modules/socket/tcp/echo_client.lua
+++ b/tests/modules/socket/tcp/echo_client.lua
@@ -5,17 +5,19 @@ function main()
local port = 9001
print("connect %s:%d ..", addr, port)
local sock = socket.connect(addr, port)
- 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