Forum Archive

FTP communication

sulcud

Hi Everyone, I know that the ftp commands are link text but how the communication actually work, for example when I want to request the content of a folder how the cliente send it for example:

Client send: “NLST
Server response:

Is it the correct format to send a ftp command?

I make and ftp server, but it only works with my own ftp client because I don’t know how the commands have to be send.

And with what socket family it work?

mikael

@sulcud, do you have a strong reason for using something as outdated and insecure as FTP? Would you consider SSH and SFTP instead? Pythonista includes the paramiko library that supports both server and client scenarios and simple file transfer operations.

sulcud

@mikael You are right, FTP is completely insecure, and yes paramiko is perfect for secure communication, but I am doing a FTP Server from scratch because I want to understand how it works inside

mikael

@sulcud, maybe take a look at an open-source C implementation like this one to get a working reference that you can translate into Python, bit by bit, while learning along the way?

dgelessus

By the way, there is a pure-Python ftplib module in the standard library, that's probably easier to read than a C version. (ftplib is only an FTP client though, not a server.)