Search code examples
c++server-sidelan

Do game servers need server-code specific to the game being played or do they simply exchange IP addresses between clients?


If I wanted to turn one of my old computers into a game server for my friends and I to play games together over (just my friends and I, this wouldn't be some sort of server for everyone everywhere playing online games to use). Does the server need to know how the game works or does a game server just tell clients where they can find other clients?

Could I do this with some basic UNIX socket programming or is this a much larger project than I expect?


Solution

  • The answer certainly depends on the game itself, but there are 3 popular choices:

    1. The game client combines some server code, so it can be run in server-mode (mostly old FPP games, since new ones don't allow players to host servers themselves),
    2. The server simply provides an interface to connect the clients and let the client-application take care of packet-exchange. This approach is mostly used by smaller, freeware games that are mostly based on some sort of co-op, where players don't have to be controlled,
    3. The game needs a special server-side application that takes care of the logic behind player actions. This is needed in most PvP games, since the server can then take care of cheating attempts.

    The 3rd approach is the most popular one, since it grants the game creators some control over their product - automatic updates, harder to obtain illegal copies that work on the network, etc.