TCP port 0 reserved for what purpose

tcptransport-protocol

I was asked a question my one of my teachers. What is TCP port 0 reserved for? I did a bit of searching and research found 2 reasons:

  1. For linux based system, to get the next available port from the OS that the program can use. Like asking for dynamically allocated ports.

  2. Packets that don't need port numbers (like ICMP) use port number 0 in their packet.

But these seemed like something that has evolved to be used for, just because port 0 was not being used for anything else. I did not find any use of port 0 that was assigned by 'IANA' in the beginning. Is there anything that was officially assigned to port 0?

Best Answer

Keep in mind that a "reserved" resource is not an "assigned" resource. Just because it is reserved doesn't mean that it is intended to be used for anything, at least at the current time. Rather it has been set aside and should not be used, unless otherwise specified.

From RFC6335:

 Reserved port numbers are not available for regular
 assignment; they are "assigned to IANA" for special purposes.
 Reserved port numbers include values at the edges of each range,
 e.g., 0, 1023, 1024, etc., which may be used to extend these
 ranges or the overall port number space in the future.