Is this how ftp works?

I just want to check if my understanding of ftp is correct. An ftp server listens at port 21. A client establishes a connection to the ftp server using a local ephemeral port that connects to the ftp server's port 21. When the ftp server sends a file to the client, it sends it from port 20, to an ephemeral port on the client's computer that is different from the one used to connect to port 21.

Is that correct? Also, what happens if multiple computers try to contact the ftp server at the same time? Do they all connect to port 21? Is there a limit to the number of simultaneous connections that can be open at a port?


Your understanding is correct.

A server port can always be accessed by multiple clients, because a TCP session is identified by 4 elements: client IP address + client port + server IP address + server port, not by the server port only.

There is also an FTP passive mode, in which it is the client that initiates the data connection to an ephemeral port on the server. This allows passing FTP traffic through some firewall or NATting devices.