Networking FTP – Does an Application to Transfer Files Between Client and Server Have to Use Port 21?

ftpnetworking

I'm taking an introduction Networking course and one of the first assignments is to make a simple file transfer application using socket API and TCP or UDP. There is a server and a client. The client can connect to the server and request to get files from the server and store them locally. The client can also send local files over to store them on the server. (side note: I'm not sure if it's relevant information but I believe the files being transferred will be regular text files)

While I was reading a textbook, I stumbled on information about 'port 21' and how the File Transfer Protocol (FTP) is assigned to that port number. I don't know much at all about FTP but my application will be "file transferring".

Therefore, my question is: will I need to set my program up to use 'Port 21' or can I use any port number? If I can use any port number then is it more 'correct' to use Port 21?

Best Answer

FTP is a specific type of transfer system and is defined by a standards document (RFC 959). Unless you plan on implementing RFC 959, your file transfer system won't be FTP and shouldn't be on port 21.

In fact, anything up to and including port 1023 is reserved for those types of well-known protocols. Ports 1024 and above are technically fair game for custom applications like yours, but there are a lot of registered port numbers in the 1024–49151 range and you may run into a conflict if you choose randomly.

Instead, I'd assign your application a port above 49151. You should generally be safe there.

Related Topic