luaevent/test/testClient.lua

changeset 2
01b3a96ae760
parent 0
f2e807614be9
child 10
88ce07d62597
--- a/luaevent/test/testClient.lua	Sun Jun 10 16:52:55 2007 +0000
+++ b/luaevent/test/testClient.lua	Mon Jun 11 01:08:59 2007 +0000
@@ -1,15 +1,22 @@
 require"luaevent"
 require"socket"
-
-local function func()
-	print("ACTIVATED")
-	local sock = socket.tcp()
-	--sock:
-	sock = luaevent.wrap(sock)
-	print(assert(sock:connect("localhost", 20000)))
-	for i = 1, 100000 do assert(sock:send("Greet me  ")) assert(sock:receive(10)) collectgarbage() end
+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
 
-luaevent.addthread(func)
-
-luaevent.loop()
\ No newline at end of file
+local function func(sock)
+	sock = luaevent.wrap(sock)
+	assert(sock:connect("localhost", 20000))
+	for i = 1, 10 do
+		for z = 1, 100 do
+			assert(sock:send("Greet me  "))
+		end
+		assert(sock:receive(10 * 100))
+	end
+end
+for i = 1, 1020 do
+	local sock = assert(socket.tcp())
+	luaevent.addthread(sock, func, sock)
+end
+luaevent.loop()

mercurial