diff --git a/FRequest/FRequest-protocol.md b/FRequest/FRequest-protocol.md new file mode 100644 index 0000000..5e1ed1c --- /dev/null +++ b/FRequest/FRequest-protocol.md @@ -0,0 +1,10 @@ +# FRequest - Simple file transfer protocol + +FRequest is a dumb 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. diff --git a/FRequest/OpenOS/usr/bin/fget.lua b/FRequest/OpenOS/usr/bin/fget.lua index 1edc610..49afdd2 100644 --- a/FRequest/OpenOS/usr/bin/fget.lua +++ b/FRequest/OpenOS/usr/bin/fget.lua @@ -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 == ""