How do games allow players to host a local multiplayer server?

Games like Terraria, Feel the Snow, Necesse, Stardew Valley, … all have an option on their main menus for creating a world which friends can join. These servers are not hosted by the developer on some cloud. They are local to host player’s machine. To my knowledge, this shouldn’t be possible without port forwarding on the router and configuring a firewall to only allow incoming traffic from specific IPs for security.

I’ve been doing some research on Nakama recently and couldn’t find info on this method of server hosting. It is all concentrated on cloud-based hosting methods. Is something like this possible with Nakama or… any other backend service? It must be, but I can’t wrap my head around how to automatically set this up from a game menu screen just by clicking a “create world” button, for example.

2 Likes

I don’t know about those games in particular, or how the gaming industry usually does it, but p2p stuff on web (like WebRTC for example) generally utilizes ICE/STUN/TURN protocols to establish better connectivity.

I believe that in many cases though, depending on the network/router configuration, you need to turn on port forwarding to host servers.