mirror of
https://github.com/lunarmodules/luasocket.git
synced 2024-12-25 20:18:21 +01:00
Fixed stupid bugs.
This commit is contained in:
parent
c3e0063b43
commit
471334c3d0
@ -26,10 +26,11 @@ local function connect(localhost, option)
|
|||||||
if option.localbind then
|
if option.localbind then
|
||||||
-- bind to a local port (if we can)
|
-- bind to a local port (if we can)
|
||||||
local localport = 721
|
local localport = 721
|
||||||
|
local done, err
|
||||||
repeat
|
repeat
|
||||||
skt = test(socket.tcp())
|
skt = test(socket.tcp())
|
||||||
try(skt:settimeout(30))
|
try(skt:settimeout(30))
|
||||||
local done, err = skt:bind(localhost, localport)
|
done, err = skt:bind(localhost, localport)
|
||||||
if not done then
|
if not done then
|
||||||
localport = localport + 1
|
localport = localport + 1
|
||||||
skt:close()
|
skt:close()
|
||||||
@ -38,6 +39,7 @@ local function connect(localhost, option)
|
|||||||
until localport > 731
|
until localport > 731
|
||||||
test(skt, err)
|
test(skt, err)
|
||||||
else skt = test(socket.tcp()) end
|
else skt = test(socket.tcp()) end
|
||||||
|
print("'" .. host .. "'")
|
||||||
try(skt:connect(host, port))
|
try(skt:connect(host, port))
|
||||||
return { skt = skt, try = try }
|
return { skt = skt, try = try }
|
||||||
end
|
end
|
||||||
|
@ -27,16 +27,14 @@ if not arg or not arg[1] then
|
|||||||
end
|
end
|
||||||
|
|
||||||
do
|
do
|
||||||
local s="opt = {"
|
local opt = {}
|
||||||
for i = 2 , table.getn(arg), 1 do
|
local pat = "[%s%c%p]*([%w]*)=([\"]?[%w%s_!@#$%%^&*()<>:;]+[\"]\?\.?)"
|
||||||
s = s .. string.gsub(arg[i],"[%s%c%p]*([%w]*)=([\"]?[%w%s_!@#$%%^&*()<>:;]+[\"]\?\.?)","%1%=\"%2\",\n")
|
for i = 2, table.getn(arg), 1 do
|
||||||
|
string.gsub(arg[i], pat, function(name, value) opt[name] = value end)
|
||||||
end
|
end
|
||||||
s = s .. "};\n"
|
|
||||||
assert(loadstring(s))();
|
|
||||||
if not arg[2] then
|
if not arg[2] then
|
||||||
return usage()
|
return usage()
|
||||||
end
|
end
|
||||||
|
|
||||||
if arg[1] ~= "query" then
|
if arg[1] ~= "query" then
|
||||||
r,e=lp.send(arg[1],opt)
|
r,e=lp.send(arg[1],opt)
|
||||||
io.stdout:write(tostring(r or e),'\n')
|
io.stdout:write(tostring(r or e),'\n')
|
||||||
|
Loading…
Reference in New Issue
Block a user