Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local host = "www.novaember.com"
- local file = "/data/test.txt"
- require("socket.http")
- local c, count = nil, 0
- function love.load()
- c = assert(socket.connect(host, 80))
- c:send("GET "..file.." HTTP/1.1\r\nHost: "..host.."\r\n\r\n")
- while true do
- local s, status = receive(c)
- print(s,status)
- count = count + string.len(s or "")
- if status == "closed" then break end
- end
- c:close()
- print(file, count)
- end
- function receive (connection)
- local s, status = connection:receive(2^10)
- if status == "timeout" then
- coroutine.yield(connection)
- end
- return s, status
- end
Advertisement
Add Comment
Please, Sign In to add comment