test/testClient.lua

Sat, 01 Sep 2007 00:24:11 -0400

author
Thomas Harning Jr <harningt@gmail.com>
date
Sat, 01 Sep 2007 00:24:11 -0400
changeset 17
1a093a31059d
parent 13
3e2ea1e7b2e8
permissions
-rw-r--r--

Refactored luaevent.lua (unlearned borked fairness, collapsing useless code).

luaevent.lua:
* Unlearned fairness since it was likely to be broken...
fairness will need to be implemented at app-level where it should be.
* Collapsed duplicate code into a local function
testClient.lua:
* Added a completion message (since the test was so quick I thought it was broken)

require"luaevent"
require"socket"
local oldPrint = print
print = function(...)
	oldPrint("CLT", ...)
end

local function func()
	print("ACTIVATED")
	local sock = socket.tcp()
	--sock:
	sock = luaevent.wrap(sock)
	print(assert(sock:connect("localhost", 20000)))
	for i = 1, 100 do assert(sock:send("Greet me  ")) assert(sock:receive(10)) collectgarbage() end
	print("COMPLETE")
end

luaevent.addthread(func)

luaevent.loop()

mercurial