Finished implementation of LuaSocket 2.0 alpha on Linux.
Some testing still needed.
This commit is contained in:
parent
f330540576
commit
71f6bb60bf
41 changed files with 700 additions and 339 deletions
|
@ -17,12 +17,14 @@ function warn(...)
|
|||
io.write("WARNING: ", s, "\n")
|
||||
end
|
||||
|
||||
pad = string.rep(" ", 8192)
|
||||
|
||||
function remote(...)
|
||||
local s = string.format(unpack(arg))
|
||||
s = string.gsub(s, "\n", ";")
|
||||
s = string.gsub(s, "%s+", " ")
|
||||
s = string.gsub(s, "^%s*", "")
|
||||
control:send(s, "\n")
|
||||
control:send(pad, s, "\n")
|
||||
control:receive()
|
||||
end
|
||||
|
||||
|
@ -82,16 +84,19 @@ function reconnect()
|
|||
remote [[
|
||||
if data then data:close() data = nil end
|
||||
data = server:accept()
|
||||
data:setoption("nodelay", true)
|
||||
]]
|
||||
data, err = socket.connect(host, port)
|
||||
if not data then fail(err)
|
||||
else pass("connected!") end
|
||||
data:setoption("nodelay", true)
|
||||
end
|
||||
|
||||
pass("attempting control connection...")
|
||||
control, err = socket.connect(host, port)
|
||||
if err then fail(err)
|
||||
else pass("connected!") end
|
||||
control:setoption("nodelay", true)
|
||||
|
||||
------------------------------------------------------------------------
|
||||
test("method registration")
|
||||
|
@ -157,16 +162,21 @@ remote "data:send(str); data:close()"
|
|||
end
|
||||
|
||||
|
||||
test_mixed(1)
|
||||
test_mixed(17)
|
||||
test_mixed(200)
|
||||
test_mixed(4091)
|
||||
test_mixed(80199)
|
||||
test_mixed(4091)
|
||||
test_mixed(200)
|
||||
test_mixed(17)
|
||||
test_mixed(1)
|
||||
--test_mixed(1)
|
||||
--test_mixed(17)
|
||||
--test_mixed(200)
|
||||
--test_mixed(4091)
|
||||
--test_mixed(80199)
|
||||
--test_mixed(4091)
|
||||
--test_mixed(200)
|
||||
--test_mixed(17)
|
||||
--test_mixed(1)
|
||||
|
||||
test_mixed(4091)
|
||||
test_mixed(4091)
|
||||
test_mixed(4091)
|
||||
test_mixed(4091)
|
||||
test_mixed(4091)
|
||||
------------------------------------------------------------------------
|
||||
test("character line")
|
||||
reconnect()
|
||||
|
|
|
@ -3,9 +3,11 @@ port = port or "8080"
|
|||
|
||||
server, error = socket.bind(host, port)
|
||||
if not server then print("server: " .. tostring(error)) os.exit() end
|
||||
ack = "\n"
|
||||
while 1 do
|
||||
print("server: waiting for client connection...");
|
||||
control = server:accept()
|
||||
control:setoption("nodelay", true)
|
||||
while 1 do
|
||||
command, error = control:receive()
|
||||
if error then
|
||||
|
@ -13,13 +15,12 @@ while 1 do
|
|||
print("server: closing connection...")
|
||||
break
|
||||
end
|
||||
sent, error = control:send("\n")
|
||||
sent, error = control:send(ack)
|
||||
if error then
|
||||
control:close()
|
||||
print("server: closing connection...")
|
||||
break
|
||||
end
|
||||
print(command);
|
||||
(loadstring(command))()
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue