There are two ways for a process to bind an Internet port number to a socket. The first one is to ask for a specific port number, which can be granted (if it is available) or not by the system. The second one is to ask the kernel for any unused port number, which will be chosen in a specific range.
Unix also supports the concept of reserved ports, which are the well-known port numbers (for standard applications such as ftp, echo...) and a few others reserved for the use of the super-user.
So we get the following port numbers and their possible use:
| Port range | |
|---|---|
| reserved for standard applications | 1-255 |
| reserved by 4.3 BSD Unix | 256-511 |
| to be used with rresvport function (root) | 512-1023 |
| automatically assignes (user clients) | 1024-5000 |
| others (user servers) | 5000 upward |