On computing and networking devices, a port serves as the entry and exit point for data traffic. The concept of a port can be viewed as both a software (virtual port) and a hardware entity (hardware port).
What is a virtual port?
The virtual port can also be called a software application port, a logical port, or a TCP/IP port. Both TCP and UDP use virtual ports to identify end-to-end connections. Unlike physical ports, virtual ports can serve more than one logical connection through a single physical connector. Virtual ports are usually entry and exit points for application traffic. A virtual port is identified by its port number. A port number 80 means HTTP web traffic, a port number 443 means secure web applications, and a port number 22 means secure telnet traffic.
A physical connector can serve more than one logical connection. Let's take an airport as an example. We have domestic airports for traveling within the country, international airports for traveling abroad, and cargo airports for delivering or shipping goods. Each and every port serves a specific purpose. It is not possible to use one airport for everything.
Similar to a TCP/IP network, a computer on a TCP/IP network has only one IP address, but can run multiple applications concurrently. A single port is not sufficient in this case. Therefore, different TCP/IP applications require different virtual ports on a computer. Using the same interface, a computer can receive different TCP/IP data traffic. A computer needs three addresses to send data to the correct service at the destination: IP address, port address (port number), and mac address. The right application data can be sent or received to/from the right destination with all three addresses.
An example where you can see different applications on my PC is using different ports.
netstat -p tcp -ano
Active Connections
Proto Local Address Foreign Address State PID
TCP 10.122.8.179:60189 52.112.120.213:443 ESTABLISHED 18284
TCP 10.122.8.179:60191 66.102.1.188:5228 ESTABLISHED 15812
TCP 10.122.8.179:60964 10.122.26.153:5061 ESTABLISHED 22988
TCP 10.122.8.179:62039 52.111.255.0:443 ESTABLISHED 15700
TCP 10.122.8.179:62069 40.113.103.199:443 ESTABLISHED 16548
TCP 10.122.8.179:62090 10.122.22.19:49684 ESTABLISHED 4876
TCP 10.122.8.179:62094 10.122.22.19:49684 ESTABLISHED 4876
You can further focus the output by using 'findstr' for specific ports, below is an example.
netstat -p tcp -ano | findstr :443
TCP 10.122.8.179:49663 40.115.3.253:443 ESTABLISHED 5344
TCP 10.122.8.179:50097 52.111.244.0:443 ESTABLISHED 15812
TCP 10.122.8.179:52558 142.250.13.94:443 TIME_WAIT 0
TCP 10.122.8.179:52571 23.36.163.236:443 ESTABLISHED 15812
TCP 10.122.8.179:52576 142.132.209.32:443 ESTABLISHED 15812
TCP 10.122.8.179:52577 142.132.209.32:443 ESTABLISHED 15812
netstat -p tcp -ano | findstr :80
TCP 0.0.0.0:80 0.0.0.0:0 LISTENING 4
TCP 10.122.8.179:52505 2.21.20.155:80 TIME_WAIT 0
TCP 10.122.8.179:52600 10.122.17.33:80 TIME_WAIT 0