Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Should I use LAN for co,op?

A topic by TheBargainBedDev created 37 days ago Views: 237 Replies: 3
Viewing posts 1 to 4

First off all sorry if this is in the wrong place I don't know what the best forum's are for specific things.

So I wanted to have some form of multiplayer in my games (Ideally across multiple computers) but I am not trying to make online competition or anything I mainly just want to allow people who know each other in real life to play together.

I am aware that LAN only works locally but considering the reasons I said above I don't really know if that is really much of a downside. From my (VERY LIMITED) understanding of networking I think LAN is supposed to be safer or more stable or something idk.

And to be clear I have yet to even make these games and I don't yet have a very good grasp of networking I just want some early advice.

Thanks. 

(2 edits) (+1)

From a programming perspective there is no difference between LAN play and Internet play. In both cases you just open a port and start listening.

The problem with Internet play is that, despite it being 2026, it is still an absolute bitch to get an Internet connection between two people running flawlessly. On top of opening a port, you need to make sure the port is forwarded correctly by your player’s router. And then, if the player is behind an ISP with a CGNAT, then that must be configured somehow as well. There’s tricks like STUN, but none of them are 100% effective and most of the time you have to fallback to a relay server you, the developer will need to host 24/7.

In theory this is something UPnP IGD, NAT-PMP and their successor, the Port Control Protocol, should be able to handle, but in a twist shocking to no one, few routers support these, and the most widespread one, UPnP, is disabled by people who have been scared into doing so without understanding why.

So yeah, in practice your players have to forward their ports manually, and that means having some basic networking knowledge, and that means just overall not being stupid, which is not going to happen.

All of that you will avoid, if you claim to support only LAN play. That being said, your players can get a VPN a la Hamachi, make a virtual local network, and play “LAN” through the Internet anyway.

EDIT: Oh, and IPv6 could not come soon enough. If I am made president

mid is right that raw ports are the pain, but for friends who know each other there’s a middle option. Have every player make an outbound connection to one small server you run, which relays a room code or runs the match. Outbound connections need no port forwarding and don’t care about CGNAT, so “join my room” just works. Pure LAN is a fair scope if you’d rather host nothing, but it can’t be played from two different houses, which is usually what real-life friends want. 🎮 Which engine are you in? The options differ a lot.

People play on the same device when they hang out with friend in real life. People play on the internet when their friends are too far away to hang out in real life. Playing over LAN means playing with people in the same building but not meeting in person, which is a less likely situation.

I mean, it does happen. I have personally played LAN games with family members in different rooms in the same building. But it’s still a less common way of interacting. Most people prefer to meet interact face-to-face when the people they’re interacting with are nearby. Most people prefer to play networked games with people who aren’t nearby. Exceptions exist, of course.