3 ms·
The port numbers are used to identify connection. If you make two connections to a web server from the same machine, the packets for each stream are separated b
by tveita 11y ago
The port numbers are used to identify connection. If you make two connections to a web server from the same machine, the packets for each stream are separated by the source port of the client.
If you got rid of the port numbers, you wouldn't just need an IP address for each service, you would need one for every outbound connection you make, and this address would need to be announced and stored in routing tables, checked for collisions, etc. Allocating ports is a lot cheaper, since only the endpoints (and stateful NATs/firewalls) need to know about them.