Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

How does a client start a server instance?

Discussion in 'Multiplayer' started by orionburcham, Mar 19, 2017.

  1. orionburcham

    orionburcham

    Joined:
    Jan 31, 2010
    Posts:
    488
    I've been learning more about Multiplayer game architecture this weekend. There are amazing resources out there, and I've been learning as much as I can about client-side prediction, physics state synchronization, packet compression, and other techniques.

    But there's something super basic I don't know, which I've had trouble finding info about: In an authoritative server setup, how does a client actually start an instance of the sim server?

    I assume there aren't servers always running, destroying some company's energy bill. So does he client call a php (or other) script on the server machine which starts a sim server with some initial parameters?

    I'm pretty sure I'm talking dumb :p, so if anyone would explain how this works, I'd be forever grateful. :)
     
  2. donnysobonny

    donnysobonny

    Joined:
    Jan 24, 2013
    Posts:
    220
    Well since you've started reading, keep going! Some tips: take a look at the client-server and peer-to-peer architectures. In short:
    • the client-server architecture involves a client-side (the game/application that you ship out to your players) and a server-side (an application that you run on a dedicated server, most likely hosted by you). In this case, you are responsible for the server-side logic
    • the peer-to-peer architecture is pretty much identical to the client-server model, except that one of the players acts as both the client AND the server. This strips back the need for you to host your own dedicated server, but the drawbacks are many...
    Definitely have a further read into these, but that should give you a basic idea of the general architectures that are used.

    To answer your question though, what you are referring to sounds like "matchmaking", which is a high-level concept normally built on top of your server architecture. The idea is:
    • you have one central server, often referred to as a "matchmaking sever"
    • this server is responsible for holding lists of available players (including rank etc) and lists of current games
    • so that players can join games, the game list contains the ip address and port that can be used to access the game
    Games themselves, or "instances" as you have referred to them, are hosted either by players (peer-to-peer) or on separate dedicated game servers (client-server). Which ever way that the game is hosted, it's ip address/port is stored on the central matchmaking server for others to be able to join.

    It can obviously get a lot more complex than this. This would really be the most basic setup. What you tend to find though is that a game's server architecture is rarely just one server. There will often be many servers, each running different server applications with different purposes.

    Hopefully this helps!
     
  3. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    In an authoritative server setup, clients don't actually start any servers. Generally you will have at least 1 server running at all times that manages players looking for games. Call this a master server, matchmaker, lobby server, whatever. Once this server sees conditions that call for a new game to start (enough players have readied up in a game lobby for example), this master server sets up a gameplay server instance in some manner (launching one from scratch, repurposing one already running, etc), and tells the clients to connect to it to start their game.