The IP address indicates the network interface (think about the network port on your computer or your WiFi connection). The port number indicates the process by which messages arriving at this network interface are sent. Therefore, you can use the same port number with different IP addresses, since they determine the port on which this interface will be listened. Note, however, that you can even reuse a port number with the same IP address if you use the SO_REUSEADDR parameter when calling the bind function.
Michael Aaron Safyan
source share