blob: 1e9e1d599d3362fee27fdd78c506dc90683d9427 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
-- 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")
|