Note: This is a question about networking, not gaming. I'm using StarCraft merely as an example.
The game StarCraft (not StarCraft 2) supports online play. One person hosts, and other people join. If the host leaves during the game, the game can continue indefinitely without the host. How does that work?
Consider the following scenario:
- I host a 3 versus 3. Note that, for people to be able to join, my router has to be configured to port forward 6112, TCP and UDP (see Blizzard Support).
- Five people join. Everyone (myself included) is behind a router. I start the game.
- Three minutes into the game, about twenty zealots pour into my base. Nobody helps me.
- My base is eliminated, so I leave (the game doesn't give you a choice).
- The game continues without the host (the home team has two players left).
How do the remaining five clients (who didn't need 6112 forwarded) remain connected?
If I understand correctly: if two programs want to talk to each other, one of them has to be a "server" and listen for connections on a port, while the other has to be a "client" and initiate a connection request on that port. They can't simply start sending packets to each other (and I don't even know how they would, if both are behind routers).
Someone hosting a game is a server, while those joining it are clients. It's easy to see how the clients can start communicating with the server. What I don't get is: how do the clients start communicating with each other without going through the server? Does the Internet Protocol allow a server to initiate connections between clients?
It's entirely possible that, in the case of StarCraft, game traffic goes through Battle.net servers. StarCraft does maintain a connection to Battle.net during games (for messages from friends, etc.). However, I doubt game traffic goes through it, because if it did, why would hosts need to port forward 6112?
My question is: can a server, with multiple clients connected to it, initiate connections between them?