added the FRequest protocol, cleaned up the client

This commit is contained in:
Izaya 2018-02-19 21:23:19 +11:00
parent 46b9a8c655
commit a1f48895d3
2 changed files with 15 additions and 5 deletions

View File

@ -0,0 +1,10 @@
# FRequest - Simple file transfer protocol
FRequest is a <del>dumb</del> simple file transfer protocol for use on Minitel networks. A file transfer occurs as follows:
1. The client initiates a connection to the server on the FRequest port (default 70)
2. The client sends the path to the file they want, followed by a newline.
3. The server responds with either the contents of the requested file, a directory listing, or "file not found" if there is an error.
4. The server closes the connection.
Servers may wish to implement restricting users to a specific directory.

View File

@ -7,14 +7,14 @@ local port = 70
local sep = host:find(":")
if sep then
port=tonumber(host:sub(sep+1))
port=tonumber(host:sub(sep+1)) or port
host=host:sub(1,sep-1)
end
local s = net.open(host,port)
s:write(path.."\n")
local socket = net.open(host,port)
socket:write(path.."\n")
repeat
l = s:read(1024)
l = socket:read(1024)
io.write(l)
os.sleep(0.5)
until s.state == "closed" and l == ""
until socket.state == "closed" and l == ""