diff options
Diffstat (limited to 'src/tp.lua')
| -rw-r--r-- | src/tp.lua | 22 |
1 files changed, 13 insertions, 9 deletions
| @@ -5,16 +5,18 @@ | |||
| 5 | -- Conforming to: RFC 2616, LTN7 | 5 | -- Conforming to: RFC 2616, LTN7 |
| 6 | -- RCS ID: $Id$ | 6 | -- RCS ID: $Id$ |
| 7 | ----------------------------------------------------------------------------- | 7 | ----------------------------------------------------------------------------- |
| 8 | -- make sure LuaSocket is loaded | ||
| 9 | require("socket") | ||
| 10 | -- get LuaSocket namespace | ||
| 11 | local socket = _G[LUASOCKET_LIBNAME] | ||
| 12 | 8 | ||
| 13 | -- create namespace inside LuaSocket namespace | 9 | ----------------------------------------------------------------------------- |
| 14 | socket.tp = socket.tp or {} | 10 | -- Load other required modules |
| 15 | -- make all module globals fall into namespace | 11 | ----------------------------------------------------------------------------- |
| 16 | setmetatable(socket.tp, { __index = _G }) | 12 | local socket = require("socket") |
| 17 | setfenv(1, socket.tp) | 13 | |
| 14 | ----------------------------------------------------------------------------- | ||
| 15 | -- Setup namespace | ||
| 16 | ----------------------------------------------------------------------------- | ||
| 17 | tp = {} | ||
| 18 | setmetatable(tp, { __index = _G }) | ||
| 19 | setfenv(1, tp) | ||
| 18 | 20 | ||
| 19 | TIMEOUT = 60 | 21 | TIMEOUT = 60 |
| 20 | 22 | ||
| @@ -107,3 +109,5 @@ function connect(host, port) | |||
| 107 | control:settimeout(TIMEOUT) | 109 | control:settimeout(TIMEOUT) |
| 108 | return setmetatable({control = control}, metat) | 110 | return setmetatable({control = control}, metat) |
| 109 | end | 111 | end |
| 112 | |||
| 113 | return tp | ||
