2.0 alpha RELEASED!
This commit is contained in:
parent
ac4aac0909
commit
7ed89c97f7
14 changed files with 480 additions and 244 deletions
16
src/ftp.lua
16
src/ftp.lua
|
@ -32,14 +32,10 @@ local metat = { __index = {} }
|
|||
|
||||
function open(server, port)
|
||||
local tp = socket.try(tp.connect(server, port or PORT, TIMEOUT))
|
||||
local f = { tp = tp }
|
||||
local f = setmetat({ tp = tp }, metat)
|
||||
-- make sure everything gets closed in an exception
|
||||
f.try = socket.newtry(function()
|
||||
tp:close()
|
||||
if f.data then f.data:close() end
|
||||
if f.server then f.server:close() end
|
||||
end)
|
||||
return setmetatable(f, metat)
|
||||
f.try = socket.newtry(function() f:close() end)
|
||||
return f
|
||||
end
|
||||
|
||||
function metat.__index:portconnect()
|
||||
|
@ -173,13 +169,9 @@ function metat.__index:quit()
|
|||
end
|
||||
|
||||
function metat.__index:close()
|
||||
self.tp:close()
|
||||
if self.data then self.data:close() end
|
||||
if self.server then self.server:close() end
|
||||
self.tp = nil
|
||||
self.data = nil
|
||||
self.server = nil
|
||||
return 1
|
||||
return self.tp:close()
|
||||
end
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue