mirror of
https://github.com/ShadowKatStudios/OC-Minitel.git
synced 2024-11-23 10:38:05 +11:00
added the FRequest protocol, cleaned up the client
This commit is contained in:
parent
46b9a8c655
commit
a1f48895d3
10
FRequest/FRequest-protocol.md
Normal file
10
FRequest/FRequest-protocol.md
Normal 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.
|
@ -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 == ""
|
||||
|
Loading…
Reference in New Issue
Block a user