--- a/luaevent/luaevent.lua Wed Jun 13 03:54:01 2007 +0000 +++ b/luaevent/luaevent.lua Wed Jun 13 04:32:12 2007 +0000 @@ -11,9 +11,6 @@ local hookedObjectMt = false --- Weak keys.. the keys are the client sockets -local clientTable = setmetatable({}, {'__mode', 'k'}) - function send(sock, data, start, stop) local s, err local from = start or 1 @@ -79,7 +76,7 @@ --cl[#cl + 1] = client client:settimeout(0) local coFunc = coroutine.wrap(clientCoroutine) - clientTable[client] = luaevent.core.addevent(client, coFunc, client, callback) + luaevent.core.addevent(client, coFunc, client, callback) end until false end @@ -103,11 +100,11 @@ function addserver(sock, callback) local coFunc = coroutine.wrap(serverCoroutine) - clientTable[sock] = luaevent.core.addevent(sock, coFunc, sock, callback) + luaevent.core.addevent(sock, coFunc, sock, callback) end function addthread(sock, func, ...) local coFunc = coroutine.wrap(func) - clientTable[sock] = luaevent.core.addevent(sock, coFunc, ...) + luaevent.core.addevent(sock, coFunc, ...) end local _skt_mt = {__index = { connect = function(self, ...) @@ -132,6 +129,9 @@ self.timeout=time return end, + close = function(self) + self.socket:close() + end }} function wrap(sock) return setmetatable({socket = sock}, _skt_mt)