A small “FTP-like” learning project built with Python TCP sockets. It supports:
get <filename>— download a file from the serverupload <filename>— upload a file to the server
The server is multi-client (thread-per-connection). File transfers are done in 1KB chunks.
This is not the real FTP protocol — just a minimal client/server exercise.
client/
client.py
sample_upload.txt
server/
server.py
sample_download.txt
- Python 3.x
- Default host/port:
127.0.0.1:5106
Open three terminals (one server, two clients).
cd .\server
python .\server.pycd .\client
python .\client.pycd .\client
python .\client.pyIn any client window:
ftp> get sample_download.txt
ftp> upload sample_upload.txt
ftp> quit
To avoid overwriting originals, outputs are written as new<Filename> with the first letter capitalized:
- After
get sample_download.txt, the client creates:client\newSample_download.txt - After
upload sample_upload.txt, the server creates:server\newSample_upload.txt
Compare file hashes in PowerShell:
# download check
Get-FileHash .\server\sample_download.txt
Get-FileHash .\client\newSample_download.txt
# upload check
Get-FileHash .\client\sample_upload.txt
Get-FileHash .\server\newSample_upload.txt- Uses a simple
EOFsentinel to mark end-of-file. TCP is a byte stream, so this repo includes a small buffer to reliably detect the marker acrossrecv()calls. - A more robust protocol would send the file size (length-prefixed framing) to avoid any chance of the marker appearing inside binary data.