aboutsummaryrefslogtreecommitdiffstats
path: root/luaevent/test/testClient.lua
diff options
context:
space:
mode:
Diffstat (limited to 'luaevent/test/testClient.lua')
-rw-r--r--luaevent/test/testClient.lua38
1 files changed, 14 insertions, 24 deletions
diff --git a/luaevent/test/testClient.lua b/luaevent/test/testClient.lua
index 8d14887..fbbcf87 100644
--- a/luaevent/test/testClient.lua
+++ b/luaevent/test/testClient.lua
@@ -1,29 +1,19 @@
require"luaevent"
require"socket"
-local function setupHook(thread)
- if not thread then debug.sethook(function(event) print("TRACE >: ", debug.getinfo(2, 'n').name) end, 'c')
- else debug.sethook(thread, function(event) print("TRACE ", thread,">: ", debug.getinfo(2, 'n').name) end, 'c') end
+local oldPrint = print
+print = function(...)
+ oldPrint("CLT", ...)
end
-local count = 100
-local function func(sock)
+
+local function func()
+ print("ACTIVATED")
+ local sock = socket.tcp()
+ --sock:
sock = luaevent.wrap(sock)
- assert(sock:connect("localhost", 20000))
- for i = 1, 2 do
- local maxZ = 10
- for z = 1, maxZ do
- assert(sock:send("Greet me "))
- end
- assert(sock:receive(10 * maxZ))
- end
- if skt then skt:close() end
- count = count - 1
- if count > 0 then
- --local sock = assert(socket.tcp())
- --luaevent.addthread(sock, func, sock)
- end
+ print(assert(sock:connect("localhost", 20000)))
+ for i = 1, 100 do assert(sock:send("Greet me ")) assert(sock:receive(10)) collectgarbage() end
end
-for i = 1, 500 do
- local sock = assert(socket.tcp())
- luaevent.addthread(sock, func, sock)
-end
-luaevent.loop()
+
+luaevent.addthread(func)
+
+luaevent.loop() \ No newline at end of file