My understanding of TCP connection is that a source PORT remains exclusive to one connection, no matter the destination is, so the number of connections from local port 12345 for example can never exceed 1.
I recently read that a TCP connection is identified by <src IP, src PORT, dst IP, dst PORT>
TCP allows source port sharing across multiple processes, but each process requires a free port to bind to for its connection
so I went to validate that "port sharing across processes": this must mean that the same source port can be used to connect to different destinations.
However, when experimenting this, I tried these two commands:
nc -v -p 12345 google.com 80
which works well (-v for verbose, and -p to specify the source port as 12345, for my learning purpose)
Now, simultaneously running this command on a different shell
nc -v -p 12345 github.com 80
fails with this error message:
nc: connectx to github.com port 80 (tcp) failed: Address already in use
the reason I specified the same source port with -p is to validate that a source port can be shared. There's no need for this practically, in real-world scenario I would not even worry about source port. According to this, is it true that a source port will be only used once?