mirror of
https://github.com/lunarmodules/luasocket.git
synced 2024-12-27 04:48:21 +01:00
26 lines
578 B
Lua
26 lines
578 B
Lua
-- load tftpclng.lua
|
|
assert(dofile("../examples/tftpclnt.lua"))
|
|
|
|
-- needs tftp server running on localhost, with root pointing to
|
|
-- /home/i/diego/public/html/luasocket/test
|
|
|
|
function readfile(file)
|
|
local f = openfile("file", "rb")
|
|
local a
|
|
if f then
|
|
a = read(f, "*a")
|
|
closefile(f)
|
|
end
|
|
return a
|
|
end
|
|
|
|
host = host or "goya"
|
|
print("downloading")
|
|
err = tftp_get(host, 69, "index.html", "index.got")
|
|
assert(not err, err)
|
|
original = readfile("index.index")
|
|
retrieved = readfile("index.got")
|
|
remove("index.got")
|
|
assert(original == retrieved, "files differ!")
|
|
print("passed")
|