Does the TCP source port have to be unique per host?
I’ve learned that a TCP connection is identified by the tuple (source IP, source port, destination ip, destination port). Theoretically, it should thus be possible to have a client from host1:port1 connect to server1:port1 and at the same time another client (running on host1) from host1:port1 to server2:port1.
I’ve tested a bit in Java, and so far it seems possible.
However, I’ve read multiple times that the source port has to be unique for the host address, which would basically mean that there is a hard limit of at most 65536 concurrent outgoing TCP connections. Is that true?
It’s not a TCP requirement. As far as TCP is concerned, only the combination of source IP, source port, destination IP, and destination port needs to be unique. However, in practice most TCP APIs don’t provide any way to create more than one connection with the same source port, unless they have different source IP addresses.
Check more discussion of this question.





