In a server, more than one user process can use TCP at the same time. To identify the data associated with each process, port numbers are used. Port numbers are 16-bit, and numbers up to 65535 are possible, although in practice only a small subset of these numbers is commonly used.
Well-known ports are used only to establish communication between client and server processes. After that, the server allocates an ephemeral port number for subsequent use. Ephemeral port numbers are unique port numbers, which are assigned dynamically when processes start communicating. They are released when communication is complete.
What are Port Numbers?
When a computer, phone or other device connects to the Internet it can run several programs.
Each program shares the same Internet connection and they can send and receive different types of data, such as web pages, emails, or instant messages.
So, how does a device know which application it should give each type of data? Because it device uses port numbers to help direct the data it receives to the correct application.
An IP address will ensure the data arrives at your device. Once there, the port number ensures that it gets to the right application.
If you compare IP addresses to a company's phone number; the port number is like an extension you dial (or option you press) that gets you through to the right person or department.
Port numbers are divided into three ranges:
- Well-known ports
- Registered ports
- Ephemeral ports
1. Well-known ports or system ports are from 0 - 1023. The operating system uses them for processes that provide widely used types of network services.
2. Registered ports have numbers from 1024 - 49151. They are for specific services that companies have registered with IANA (The Internet Assigned Numbers Authority oversees Internet Protocol-related symbols and numbers such as IP address allocation, media types, and port numbers.)
3. Ephemeral ports have numbers from 49152-65535, they are used for temporary purposes (such as tabs in a browser) also known as dynamic or private ports. They are used for private, customized services, or for termportary purposes