summaryrefslogtreecommitdiff
path: root/tests/modules/socket/tcp/echo_server.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tests/modules/socket/tcp/echo_server.lua')
-rw-r--r--tests/modules/socket/tcp/echo_server.lua8
1 files changed, 6 insertions, 2 deletions
diff --git a/tests/modules/socket/tcp/echo_server.lua b/tests/modules/socket/tcp/echo_server.lua
index 162bc2bc0..048db0c37 100644
--- a/tests/modules/socket/tcp/echo_server.lua
+++ b/tests/modules/socket/tcp/echo_server.lua
@@ -1,3 +1,4 @@
+import("core.base.bytes")
import("core.base.socket")
function main()
@@ -13,8 +14,9 @@ function main()
print("%s: accepted", sock_client)
local count = 0
local result = nil
+ local buff = bytes(8192)
while true do
- local recv, data = sock_client:recv(13, {block = true})
+ local recv, data = sock_client:recv(buff, 13, {block = true})
if recv > 0 then
result = data
sock_client:send(data, {block = true})
@@ -24,7 +26,9 @@ function main()
end
end
print("%s: recv: %d, count: %d", sock_client, result and result:size() or 0, count)
- result:dump()
+ if result then
+ result:dump()
+ end
sock_client:close()
end
end