28 lines
2.1 KiB
Markdown
28 lines
2.1 KiB
Markdown
|
# Simple "FTP" Server
|
||
|
|
||
|
Putting "FTP" in quotes here because this certainly does not conform to the FTP spec!
|
||
|
|
||
|
This project implements a TCP server (`server.py`) and a client program that can issue a few commands to it (`client.py`). This isn't meant to be generally useful; with some very basic modifications it should actually be able to run on two different devices, but as is the server and client both need to be run on localhost. It was, however, a fun project, and one of the few complete projects I'm able to share that shows I'm comfortable using Python, so I figured I'd upload it.
|
||
|
|
||
|
The client program recognizes the following commands:
|
||
|
```
|
||
|
OPEN [port number] Establish connection to server at 127.0.0.1:[port number]
|
||
|
CLOSE Close the current connection
|
||
|
QUIT Close connection (if open) and exit
|
||
|
GET [file name] Download 'file_name' from the server ("./server")
|
||
|
PUT [file name] Upload 'file_name' from the client ("./client")
|
||
|
```
|
||
|
|
||
|
## Notes
|
||
|
The server handles these commands a bit differently (e.g. when you execute `PUT file` it actually translates it to `PUT <file> <size in bytes>` automatically so the server knows how much it's getting; you cannot, however, run the full command on your own). The server also has the extra command `SIZE <file>`, used as a part of `GET <file>` to negotiate the transfer, but the client won't recognize it if you were to execute it during a session.
|
||
|
|
||
|
Commands are case-insensitive
|
||
|
|
||
|
You can start the server on another port by passing it an argument (i.e. `python server.py 8080`). You could also start more than one server that way, but note that they'll both use the same `./server/` directory.
|
||
|
|
||
|
The client will attempt to autoconnect to `127.0.0.1:12000`. If you haven't already started the server without specifying a port, the connection will be refused and you can try again by running `open <port>`
|
||
|
|
||
|
Files may be within sub-directories; the full path will be created where it lands.
|
||
|
|
||
|
The server has a configurable max file size (64KiB). You can configure it to be less, but if you can't set it to anything higher than 64KiB. If you do, the server will send at most 64KiB.
|