luasocket/test/tftptest.lua

26 lines
583 B
Lua
Raw Normal View History

2001-01-25 22:59:39 +01:00
-- 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
2001-09-25 23:32:52 +02:00
function readfile(file)
local f = openfile("file", "rb")
local a
if f then
a = read(f, "*a")
closefile(f)
end
return a
end
2002-07-08 23:56:57 +02:00
host = host or "localhost"
2001-01-25 22:59:39 +01:00
print("downloading")
2001-09-25 23:32:52 +02:00
err = tftp_get(host, 69, "index.html", "index.got")
2001-01-25 22:59:39 +01:00
assert(not err, err)
2001-09-25 23:32:52 +02:00
original = readfile("index.index")
retrieved = readfile("index.got")
remove("index.got")
2001-01-25 22:59:39 +01:00
assert(original == retrieved, "files differ!")
print("passed")