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/smtp.lua | |
| parent | ac4aac0909da26befaaeb6b415f66cf35b6980e0 (diff) | |
| download | luasocket-7ed89c97f760600df238f9853ee453570935870f.tar.gz luasocket-7ed89c97f760600df238f9853ee453570935870f.tar.bz2 luasocket-7ed89c97f760600df238f9853ee453570935870f.zip | |
2.0 alpha RELEASED!
Diffstat (limited to 'src/smtp.lua')
| -rw-r--r-- | src/smtp.lua | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/smtp.lua b/src/smtp.lua index d6357d2..70b511c 100644 --- a/src/smtp.lua +++ b/src/smtp.lua | |||
| @@ -60,7 +60,7 @@ function metat.__index:quit() | |||
| 60 | end | 60 | end |
| 61 | 61 | ||
| 62 | function metat.__index:close() | 62 | function metat.__index:close() |
| 63 | return self.try(self.tp:close()) | 63 | return self.tp:close() |
| 64 | end | 64 | end |
| 65 | 65 | ||
| 66 | function metat.__index:login(user, password) | 66 | function metat.__index:login(user, password) |
| @@ -104,9 +104,10 @@ end | |||
| 104 | 104 | ||
| 105 | function open(server, port) | 105 | function open(server, port) |
| 106 | local tp = socket.try(tp.connect(server or SERVER, port or PORT, TIMEOUT)) | 106 | local tp = socket.try(tp.connect(server or SERVER, port or PORT, TIMEOUT)) |
| 107 | local s = setmetatable({tp = tp}, metat) | ||
| 107 | -- make sure tp is closed if we get an exception | 108 | -- make sure tp is closed if we get an exception |
| 108 | local try = socket.newtry(function() tp:close() end) | 109 | local try = socket.newtry(function() s:close() end) |
| 109 | return setmetatable({ tp = tp, try = try}, metat) | 110 | return s |
| 110 | end | 111 | end |
| 111 | 112 | ||
| 112 | --------------------------------------------------------------------------- | 113 | --------------------------------------------------------------------------- |
