我一直试图弄清楚如何睡眠 Lua脚本几秒钟才能继续。我在我的代码中使用了 sleep 函数,但是我收到了错误。
local socket = require("socket")
host = host or "*"
port = port or 8080
if arg
then
host = arg[1] or host
port = arg[2] or port
end
print("Binding to host '" ..host.. "' and port " ..port.. "...")
s = assert(socket.bind(host, port))
i, p = s:getsockname()
assert(i, p)
print("Waiting connection from talker on " .. i .. ":" .. p .. "...")
c = assert(s:accept())
print("Connected. Here is the stuff:")
l = io.read()
while l and l ~= "" and not e
do
assert(c:send(l .. "\n"))
function sleep(10)
os.execute("sleep " .. tonumber(10))
end
end
print(e)
有人可以帮帮我吗?