What is the largest TCP/IP network port number allowable for IPv4?

前端 未结 8 1579
走了就别回头了
走了就别回头了 2020-11-29 16:19

What is the highest port number one can use?

8条回答
  •  一个人的身影
    2020-11-29 16:44

    According to RFC 793, the port is a 16 bit unsigned int.

    This means the range is 0 - 65535.

    However, within that range, ports 0 - 1023 are generally reserved for specific purposes. I say generally because, apart from port 0, there is usually no enforcement of the 0-1023 reservation. TCP/UDP implementations usually don't enforce reservations apart from 0. You can, if you want to, run up a web server's TLS port on port 80, or 25, or 65535 instead of the standard 443. Likewise, even tho it is the standard that SMTP servers listen on port 25, you can run it on 80, 443, or others.

    Most implementations reserve 0 for a specific purpose - random port assignment. So in most implementations, saying "listen on port 0" actually means "I don't care what port I use, just give me some random unassigned port to listen on".

    So any limitation on using a port in the 0-65535 range, including 0, ephemeral reservation range etc, is implementation (i.e. OS/driver) specific, however all, including 0, are valid ports in the RFC 793.

提交回复
热议问题