diff options
Diffstat (limited to '')
-rw-r--r-- | src/tp.lua | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -46,6 +46,14 @@ end | |||
46 | -- metatable for sock object | 46 | -- metatable for sock object |
47 | local metat = { __index = {} } | 47 | local metat = { __index = {} } |
48 | 48 | ||
49 | function metat.__index:getpeername() | ||
50 | return self.c:getpeername() | ||
51 | end | ||
52 | |||
53 | function metat.__index:getsockname() | ||
54 | return self.c:getpeername() | ||
55 | end | ||
56 | |||
49 | function metat.__index:check(ok) | 57 | function metat.__index:check(ok) |
50 | local code, reply = get_reply(self.c) | 58 | local code, reply = get_reply(self.c) |
51 | if not code then return nil, reply end | 59 | if not code then return nil, reply end |
@@ -74,7 +82,7 @@ function metat.__index:command(cmd, arg) | |||
74 | end | 82 | end |
75 | 83 | ||
76 | function metat.__index:sink(snk, pat) | 84 | function metat.__index:sink(snk, pat) |
77 | local chunk, err = c:receive(pat) | 85 | local chunk, err = self.c:receive(pat) |
78 | return snk(chunk, err) | 86 | return snk(chunk, err) |
79 | end | 87 | end |
80 | 88 | ||
@@ -123,4 +131,4 @@ function _M.connect(host, port, timeout, create) | |||
123 | return base.setmetatable({c = c}, metat) | 131 | return base.setmetatable({c = c}, metat) |
124 | end | 132 | end |
125 | 133 | ||
126 | return _M \ No newline at end of file | 134 | return _M |