With TCP, you can only have one process listening on a port, but when it accepts a connection (like yours), you get a full socket descriptor to continue the session so you can return and listen to the original descriptor descriptor for another connection.
Uniqueness in TCP is at the session level. In other words, the 5-tuple (source-ip, source-port, dest-ip, dest-port, protocol) must be unique so that packets do not get confused about where they are going.
You can have thousands of clients talking to this dest-ip / dest-port pair (for example, a large number of people who click stackoverflow.com:80 right now).
So yes, you are allowed to do what you do.
What can you find if you try to bind this port while there are still sessions in the TIME_WAIT state, you will not be able to bind. This means that any live packets from a previous session on the network will not log in and will not ruin your session.
Further information on TIME_WAIT and why this is necessary can be found in this excellent answer :-)
paxdiablo
source share