diff options
author | Luigi Scarso <luigi.scarso@gmail.com> | 2018-01-17 18:00:12 +0000 |
---|---|---|
committer | Luigi Scarso <luigi.scarso@gmail.com> | 2018-01-17 18:00:12 +0000 |
commit | f100e939b3262ac391fe767d591d1a316ab59f3a (patch) | |
tree | 53787d7aa79da3a8b10df0049cfe623cf0f2bd89 /Build/source/texk/web2c/luatexdir/luasocket/src/tp.lua | |
parent | 345e6b3ddab394ae88cd0d916992bc2bc0f8695d (diff) |
Luatex 1.07 --- luatex and luatex53
git-svn-id: svn://tug.org/texlive/trunk@46348 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c/luatexdir/luasocket/src/tp.lua')
-rw-r--r-- | Build/source/texk/web2c/luatexdir/luasocket/src/tp.lua | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/Build/source/texk/web2c/luatexdir/luasocket/src/tp.lua b/Build/source/texk/web2c/luatexdir/luasocket/src/tp.lua index 2ffe9a45818..ea88353838d 100644 --- a/Build/source/texk/web2c/luatexdir/luasocket/src/tp.lua +++ b/Build/source/texk/web2c/luatexdir/luasocket/src/tp.lua @@ -9,14 +9,16 @@ ----------------------------------------------------------------------------- local base = _G local string = require("string") -local socket = require("socket") -local ltn12 = require("ltn12") -module("socket.tp") +local socket = socket or require("socket") +local ltn12 = ltn12 or require("ltn12") + +socket.tp = {} +local _M = socket.tp ----------------------------------------------------------------------------- -- Program constants ----------------------------------------------------------------------------- -TIMEOUT = 60 +_M.TIMEOUT = 60 ----------------------------------------------------------------------------- -- Implementation @@ -44,6 +46,14 @@ end -- metatable for sock object local metat = { __index = {} } +function metat.__index:getpeername() + return self.c:getpeername() +end + +function metat.__index:getsockname() + return self.c:getpeername() +end + function metat.__index:check(ok) local code, reply = get_reply(self.c) if not code then return nil, reply end @@ -72,7 +82,7 @@ function metat.__index:command(cmd, arg) end function metat.__index:sink(snk, pat) - local chunk, err = c:receive(pat) + local chunk, err = self.c:receive(pat) return snk(chunk, err) end @@ -109,10 +119,10 @@ function metat.__index:close() end -- connect with server and return c object -function connect(host, port, timeout, create) +function _M.connect(host, port, timeout, create) local c, e = (create or socket.tcp)() if not c then return nil, e end - c:settimeout(timeout or TIMEOUT) + c:settimeout(timeout or _M.TIMEOUT) local r, e = c:connect(host, port) if not r then c:close() @@ -121,3 +131,4 @@ function connect(host, port, timeout, create) return base.setmetatable({c = c}, metat) end +return _M |