This is something I've never quite understood: A service offered by a server can be uniquely identified by its IP address and port, for example 188.8.131.52:22, but multiple clients might connect to the same port at the same time. When the different clients send new data to the server, how does the server distinguish between them so that it can route the data differently?
For example, when a server allows SSH connections, it will open port 22 by default. Multiple SSH clients can connect so that multiple people can be using SSH at the same time, and they will all be using port 22. I believe that on the server, the different sessions are distinguished by having different sockets, one for each session, though I could be wrong about that.
But if that is the case, when a particular user enters a new command during their SSH session, how does the server know which socket to route that command to? The user's computer doesn't have access to the socket descriptor, they only have the IP address and port, so I don't see how they could send enough information to the server to allow it to distinguish between their session and another session. Does the server distinguish based on the IP address and port of the client, or does it do something else?