I'm not great at networking concepts, but my basic understanding is that computer networking relies on constructs like IP addresses and port numbers to direct data packets to the correct device and application.
So, if I'm playing an online game like Minecraft or Counter-Strike, I am able to connect to the dedicated game server using the server's IP address (which might be associated with a physical device, or a virtual device like a VM or a OCI container) and port number (which is like a communication "channel", associated with a particular piece of software).
And, as such, you can host multiple game server instances for the same game on different IPs or ports, as long as each server has some way to be individually addressed.
But I start to get a bit confused when I think about the packet's return trip and how the server communicates back to the clients...
In some cases, each client will be connecting from their own network modem, with their own IP address assigned to them dynamically or statically by their ISP. In that case, I would imagine that the server could just keep a list of client connections and route relevant data back to each client.
But in other cases, you might have a multiple clients playing a game behind one modem (like housemates or a LAN party where multiple players join the same remote/internet server), or a newer problem, multiple different networks sharing an IP address due to CG-NAT at the ISP level. In which case, from the perspective of the server, multiple players would be playing from the same IP address and communicating over the same port, right?
So how does the server differentiate between >2 players connecting from the same IP address and communicating over the same port?
Or does it not even try, and instead just broadcast all of the relevant game data to every client?
And if that's the case, how do huge games like battle royales or MMOs handle sending game state to a large number of users?