diff options
| author | Diego Nehab <diego@tecgraf.puc-rio.br> | 2004-06-18 21:41:44 +0000 |
|---|---|---|
| committer | Diego Nehab <diego@tecgraf.puc-rio.br> | 2004-06-18 21:41:44 +0000 |
| commit | 7ed89c97f760600df238f9853ee453570935870f (patch) | |
| tree | a17573a43815071e35f85557519fefca739ef7ef /src/ftp.lua | |
| parent | ac4aac0909da26befaaeb6b415f66cf35b6980e0 (diff) | |
| download | luasocket-7ed89c97f760600df238f9853ee453570935870f.tar.gz luasocket-7ed89c97f760600df238f9853ee453570935870f.tar.bz2 luasocket-7ed89c97f760600df238f9853ee453570935870f.zip | |
2.0 alpha RELEASED!
Diffstat (limited to 'src/ftp.lua')
| -rw-r--r-- | src/ftp.lua | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/src/ftp.lua b/src/ftp.lua index ad02c72..1c7ea71 100644 --- a/src/ftp.lua +++ b/src/ftp.lua | |||
| @@ -32,14 +32,10 @@ local metat = { __index = {} } | |||
| 32 | 32 | ||
| 33 | function open(server, port) | 33 | function open(server, port) |
| 34 | local tp = socket.try(tp.connect(server, port or PORT, TIMEOUT)) | 34 | local tp = socket.try(tp.connect(server, port or PORT, TIMEOUT)) |
| 35 | local f = { tp = tp } | 35 | local f = setmetat({ tp = tp }, metat) |
| 36 | -- make sure everything gets closed in an exception | 36 | -- make sure everything gets closed in an exception |
| 37 | f.try = socket.newtry(function() | 37 | f.try = socket.newtry(function() f:close() end) |
| 38 | tp:close() | 38 | return f |
| 39 | if f.data then f.data:close() end | ||
| 40 | if f.server then f.server:close() end | ||
| 41 | end) | ||
| 42 | return setmetatable(f, metat) | ||
| 43 | end | 39 | end |
| 44 | 40 | ||
| 45 | function metat.__index:portconnect() | 41 | function metat.__index:portconnect() |
| @@ -173,13 +169,9 @@ function metat.__index:quit() | |||
| 173 | end | 169 | end |
| 174 | 170 | ||
| 175 | function metat.__index:close() | 171 | function metat.__index:close() |
| 176 | self.tp:close() | ||
| 177 | if self.data then self.data:close() end | 172 | if self.data then self.data:close() end |
| 178 | if self.server then self.server:close() end | 173 | if self.server then self.server:close() end |
| 179 | self.tp = nil | 174 | return self.tp:close() |
| 180 | self.data = nil | ||
| 181 | self.server = nil | ||
| 182 | return 1 | ||
| 183 | end | 175 | end |
| 184 | 176 | ||
| 185 | ----------------------------------------------------------------------------- | 177 | ----------------------------------------------------------------------------- |
