2

I've been trying to figure out how to sleep a Lua script for a number of seconds before continuing. I have used sleep function in my code, but I'm getting an error.

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) 

Can anyone help me out please?

0 Answers0