This is not the most common design, but have a look at the following output:
remote local state *:* - 126.96.36.199:5000 LISTENING 188.8.131.52:12345 - 184.108.40.206:5000 CONNECTED 220.127.116.11:83247 - 18.104.22.168:5000 CONNECTED
What needs to be unique, is the 5-tuple
(protocol, remote-ip, remote-port, local-ip, local-port)… so this situation can exist. [[tcp/ip sockets in C]] P100 has a full section on this topic.
http://stackoverflow.com/questions/11129212/tcp-two-different-sockets-sharing-a-port also says “Multiple worker-sockets on the same TCP server can share the same server-side IP/Port pair as long as they are associated with different client-side IP/Port pairs”. This “accept, move the connection to a dedicated server socket, then go back to accept()” is the common design — On each incoming connection, the listening TCP server will start a new thread/task/process using a new “worker” socket on the server side. Note the new worker socket shares server ip:port with the original listening socket
https://github.com/tiger40490/repo1/blob/py1/py/sock/1sock2server.py is my experiment. It pushes the concept of “sharing” further — two TCP serves sharing a single socket not just a single ip:port endpoint!