Ephemeral port reuse for TCP connections to different IP addresses

porttcptcpip

I know that a web server running a website on TCP port 80 can receive TCP connections from many different IP addresses sourced from many different ephemeral ports.

Can a client initiate multiple connections (complete the TCP 3-way handshake) to different web servers on TCP port 80 using the same ephemeral port?

For example:

Source Port: 55555, Destination Port: 80, Destination IP: 1.1.1.1
Source Port: 55555, Destination Port: 80, Destination IP: 2.2.2.2
Source Port: 55555, Destination Port: 80, Destination IP: 3.3.3.3

Best Answer

If the first connection using port 55555 has been closed, it may be reused by any application. If an application tries to open the same port which is used by another application, the OS will respond that the port is already in use.

One caveat is that the application which has opened the port with TCP can use it as it see fit, including using it for multiple servers, but all the multiplexing work is on the application, not TCP.