aboutsummaryrefslogtreecommitdiff
path: root/src/tp.lua
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/tp.lua12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/tp.lua b/src/tp.lua
index cbeff56..b8ebc56 100644
--- a/src/tp.lua
+++ b/src/tp.lua
@@ -46,6 +46,14 @@ end
46-- metatable for sock object 46-- metatable for sock object
47local metat = { __index = {} } 47local metat = { __index = {} }
48 48
49function metat.__index:getpeername()
50 return self.c:getpeername()
51end
52
53function metat.__index:getsockname()
54 return self.c:getpeername()
55end
56
49function metat.__index:check(ok) 57function 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)
74end 82end
75 83
76function metat.__index:sink(snk, pat) 84function 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)
79end 87end
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)
124end 132end
125 133
126return _M \ No newline at end of file 134return _M