Mon, 11 Jun 2007 01:08:59 +0000
* Completed mostly working version
* Moved to a mode where addevent calls a callback rather than
it being instantiated within.
* If the callback returns -1, then no event is ever setup
* Otherwise the integer value is used to setup the event
* This allows for using coroutine.wrap rather than a cooked-up wrapper
* Tests work, although there are a few remaining issues:
* Need to figure a good way of preserving the event object,
not sure if current method is good enough, since the socket
is the only anchor, and it is only held inside the coro..
circular reference, something that Lua 'handles' well.
* Doing more than the maximum sockets the process is allows
causes strangeness to occur in libevent.. somehow
it is getting around to epoll_add which is causing valgrind
to barf.
-- Tests Copas with a simple Echo server -- -- Run the test file and the connect to the server by telnet on the used port -- to stop the test just send the command "quit" require"luaevent" require"socket" local function echoHandler(skt) while true do local data,ret = luaevent.receive(skt, 10) if data == "quit" or ret == 'closed' then break end --collectgarbage() luaevent.send(skt, data) end end local server = assert(socket.bind("localhost", 20000)) server:settimeout(0) luaevent.addserver(server, echoHandler) luaevent.loop()