test/testClient.lua

Wed, 03 Mar 2010 18:19:20 -0600

author
James Snyder <jbsnyder@fanplastic.org>
date
Wed, 03 Mar 2010 18:19:20 -0600
changeset 101
f5369fe8f107
parent 17
1a093a31059d
permissions
-rw-r--r--

Changes to compile on OS X.

- BSD version of install doesn't have -D flag
- stdlib.h should include malloc defs (malloc.h is obsolete)

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