mirror of
https://github.com/lunarmodules/luasocket.git
synced 2024-12-26 12:28:21 +01:00
Seems good.
This commit is contained in:
parent
1812d6ce15
commit
596602f2ca
@ -76,7 +76,7 @@ RFC 1179
|
|||||||
-- gets server acknowledement
|
-- gets server acknowledement
|
||||||
local function recv_ack(con)
|
local function recv_ack(con)
|
||||||
local ack = con.skt:receive(1)
|
local ack = con.skt:receive(1)
|
||||||
con.try(string.char(0) == ack, "failed to receive server acknowledement")
|
con.try(string.char(0) == ack, "failed to receive server acknowledgement")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- sends client acknowledement
|
-- sends client acknowledement
|
||||||
@ -166,7 +166,7 @@ local function send_hdr(con, control)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function send_control(con, control)
|
local function send_control(con, control)
|
||||||
local sent = con:send(control)
|
local sent = con.skt:send(control)
|
||||||
con.try(sent and sent >= 1, "failed to send control file")
|
con.try(sent and sent >= 1, "failed to send control file")
|
||||||
send_ack(con)
|
send_ack(con)
|
||||||
end
|
end
|
||||||
@ -176,7 +176,7 @@ local function send_data(con,fh,size)
|
|||||||
while size > 0 do
|
while size > 0 do
|
||||||
buf,message = fh:read(8192)
|
buf,message = fh:read(8192)
|
||||||
if buf then
|
if buf then
|
||||||
st = con.try(con:send(buf))
|
st = con.try(con.skt:send(buf))
|
||||||
size = size - st
|
size = size - st
|
||||||
else
|
else
|
||||||
con.try(size == 0, "file size mismatch")
|
con.try(size == 0, "file size mismatch")
|
||||||
@ -303,7 +303,7 @@ query = socket.protect(function(p)
|
|||||||
if string.sub(p.format or 's',1,1) == 's' then fmt = 3 else fmt = 4 end
|
if string.sub(p.format or 's',1,1) == 's' then fmt = 3 else fmt = 4 end
|
||||||
con.try(con.skt:send(string.format("%c%s %s\n", fmt, p.queue or "*",
|
con.try(con.skt:send(string.format("%c%s %s\n", fmt, p.queue or "*",
|
||||||
p.list or "")))
|
p.list or "")))
|
||||||
local data = ltry(connection:receive("*a"))
|
local data = con.try(con.skt:receive("*a"))
|
||||||
con.skt:close()
|
con.skt:close()
|
||||||
return data
|
return data
|
||||||
end)
|
end)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
local lp = require("lp")
|
local lp = require("lp")
|
||||||
|
|
||||||
local function usage()
|
local function usage()
|
||||||
print('\nUsage: lp filename [keyword=val...]\n')
|
print('\nUsage: lua lptest.lua [filename] [keyword=val...]\n')
|
||||||
print('Valid keywords are :')
|
print('Valid keywords are :')
|
||||||
print(
|
print(
|
||||||
' host=remote host or IP address (default "localhost")\n' ..
|
' host=remote host or IP address (default "localhost")\n' ..
|
||||||
@ -36,12 +36,13 @@ do
|
|||||||
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.stderr:write(tostring(r or e),'\n')
|
io.stdout:write(tostring(r or e),'\n')
|
||||||
else
|
else
|
||||||
r,e=lp.query(opt)
|
r,e=lp.query(opt)
|
||||||
io.stderr:write(tostring(r or e), '\n')
|
io.stdout:write(tostring(r or e), '\n')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -347,5 +347,7 @@ const char *sock_strerror(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const char *sock_geterr(p_sock ps, int code) {
|
const char *sock_geterr(p_sock ps, int code) {
|
||||||
|
(void) ps;
|
||||||
|
(void) code;
|
||||||
return sock_strerror();
|
return sock_strerror();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user