1

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?

  • 2
    Is your application going to use this protocol (FTP)? If not, it shouldn't use the port reserved for that protocol. – Oded Sep 18 '15 at 16:36
7

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.

  • Good answer, though I would put some emphasis on avoiding re-inventing the wheel and especially creating your own format where at all possible. – Deduplicator Sep 18 '15 at 16:50
  • Thank you for the response! I believe I get it. So FTP is just a different type of protocol just as TCP and UDP are different protocols? So even though I am making something for basic "file transfer" that doesn't actually mean I am using or need to use the "File Transfer Protocol", correct? – Shawn Sep 18 '15 at 16:56
  • @Shawn kinda: there's a layering of protocols called the OSI model: FTP is part of the application layer and it's built on top of TCP which is part of the transport layer. When you use FTP, you're using TCP as well. But you otherwise have it! – Evan Sep 18 '15 at 17:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.