Closer to release...

This commit is contained in:
Diego Nehab 2003-03-28 21:08:50 +00:00
parent 307603b24d
commit f18d1b7cd0
31 changed files with 163 additions and 77 deletions

View file

@ -60,7 +60,7 @@ local empty = function()
end
local get = function()
s = ""
local s = ""
for i,v in ipairs(files) do
s = s .. "\n" .. readfile(v)
end

View file

@ -1,5 +1,5 @@
HOST = HOST or "localhost"
PORT = PORT or "8080"
host = host or "localhost"
port = port or "8080"
function pass(...)
local s = string.format(unpack(arg))
@ -83,14 +83,14 @@ function tcpreconnect()
if data then data:close() data = nil end
data = server:accept()
]]
data, err = socket.connect(HOST, PORT)
data, err = socket.connect(host, port)
if not data then fail(err)
else pass("connected!") end
end
reconnect = tcpreconnect
pass("attempting control connection...")
control, err = socket.connect(HOST, PORT)
control, err = socket.connect(host, port)
if err then fail(err)
else pass("connected!") end
@ -104,10 +104,10 @@ function empty_connect()
if data then data:close() data = nil end
data = server:accept()
]]
data, err = socket.connect("", PORT)
data, err = socket.connect("", port)
if not data then
pass("ok")
data = socket.connect(HOST, PORT)
data = socket.connect(host, port)
else fail("should not have connected!") end
end

View file

@ -1,7 +1,7 @@
HOST = HOST or "localhost"
PORT = PORT or "8080"
host = host or "localhost"
port = port or "8080"
server, error = socket.bind(HOST, PORT)
server, error = socket.bind(host, port)
if not server then print("server: " .. tostring(error)) os.exit() end
while 1 do
print("server: waiting for client connection...");

View file

@ -1,25 +1,23 @@
-- load tftpclng.lua
assert(dofile("../examples/tftpclnt.lua"))
-- load tftpclnt.lua
dofile("tftpclnt.lua")
-- needs tftp server running on localhost, with root pointing to
-- /home/i/diego/public/html/luasocket/test
-- a directory with index.html in it
function readfile(file)
local f = openfile("file", "rb")
local a
if f then
a = read(f, "*a")
closefile(f)
end
return a
local f = io.open(file, "r")
if not f then return nil end
local a = f:read("*a")
f:close()
return a
end
host = host or "localhost"
print("downloading")
err = tftp_get(host, 69, "index.html", "index.got")
assert(not err, err)
original = readfile("index.index")
original = readfile("test/index.html")
retrieved = readfile("index.got")
remove("index.got")
os.remove("index.got")
assert(original == retrieved, "files differ!")
print("passed")

View file

@ -1,5 +1,4 @@
dofile("noglobals.lua")
local check_build_url = function(parsed)
local built = socket.url.build(parsed)