aboutsummaryrefslogtreecommitdiffstats
path: root/luaevent/test/testClient.lua
diff options
context:
space:
mode:
authorThomas Harning Jr <harningt@gmail.com>2007-06-13 04:32:12 +0000
committerThomas Harning Jr <harningt@gmail.com>2007-06-13 04:32:12 +0000
commitdbea9370eb58cdc3cbd1b12d8c8735582370cd6e (patch)
tree80526dffa240d3eca832114e98490f9632925176 /luaevent/test/testClient.lua
parenta309c7952c6ae1b9ad9c9c0c0d895e1ad969cb95 (diff)
downloadluaevent-prosody-dbea9370eb58cdc3cbd1b12d8c8735582370cd6e.tar.gz
luaevent-prosody-dbea9370eb58cdc3cbd1b12d8c8735582370cd6e.zip
Setup management of socket create/close.
Recognized new bug: cannot create threads within threads... C contains reference to closed thread, not global.
Diffstat (limited to 'luaevent/test/testClient.lua')
-rw-r--r--luaevent/test/testClient.lua17
1 files changed, 12 insertions, 5 deletions
diff --git a/luaevent/test/testClient.lua b/luaevent/test/testClient.lua
index 0557230..8d14887 100644
--- a/luaevent/test/testClient.lua
+++ b/luaevent/test/testClient.lua
@@ -4,18 +4,25 @@ 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
end
-
+local count = 100
local function func(sock)
sock = luaevent.wrap(sock)
assert(sock:connect("localhost", 20000))
- for i = 1, 10 do
- for z = 1, 100 do
+ for i = 1, 2 do
+ local maxZ = 10
+ for z = 1, maxZ do
assert(sock:send("Greet me "))
end
- assert(sock:receive(10 * 100))
+ 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
end
-for i = 1, 1020 do
+for i = 1, 500 do
local sock = assert(socket.tcp())
luaevent.addthread(sock, func, sock)
end