LAN Multiplayer Made Simple
Drop-in networking library for .NET and Unity. Discover servers over UDP, sync state over UDP, and reliably command over TCP — all on your local network.
Why Choose Lan Multiplayer?
Everything you need to add local multiplayer to your game, without the complexity.
Easy Integration
Simple API that works with both .NET and Unity projects. Get started in minutes.
LAN-First
Optimized for local area networks — Wi-Fi and wired — with low latency discovery.
Real-Time State Sync
Unreliable UDP channel for 30-60 FPS state updates with no head-of-line blocking.
High Performance
Binary framed protocol, NoDelay, SocketAsyncEventArgs I/O, and GZip compression.
Cross-Platform
Windows, Linux, macOS, Android, and iOS from a single codebase.
Well Documented
Comprehensive docs and copy-paste examples for common multiplayer patterns.
Quick Examples
Copy, paste, and adapt these snippets to your project.
1. Server Discovery
Automatically discover LAN servers using UDP broadcast:
// Start broadcast discovery
Multiplayer.StartBroadcastClient(
platform: EPlatform.Standalone,
request: new AppMessage(1, "my-game", JsonUtility.ToJson(Command.New("discover"))),
onReceiveResponse: (LocatedMessage response) => {
ServerInfo serverInfo = JsonUtility.FromJson(response.Message.Message);
Console.WriteLine($"Found server: {serverInfo.Name} at {response.IPEndPoint}");
},
receiveResponsesMilliseconds: 5000,
repeatAfterMilliseconds: 5000
);
2. Start a Server
Create and start a multiplayer server:
// Configure server
Multiplayer.Name = "My Game Server";
Multiplayer.IpAddress = Lan.LocalIPv4Addresses(EPlatform.Standalone)[0];
// Start server with game data
Multiplayer.StartServer(
platform: EPlatform.Standalone,
serverGameData: new ServerGameData(Guid.NewGuid().ToString()),
processMessage: (LocatedMessage msg) => {
// Handle discovery requests
return new AppMessage(1, "my-game", JsonUtility.ToJson(Command.New("server-info")));
},
receiveRequestsDelayMilliseconds: 500
);
3. Connect as Client
Connect to a discovered server:
// Set connection parameters
Multiplayer.IpAddress = serverIpAddress;
Multiplayer.Port = serverPort;
// Start client
Multiplayer.StartClient();
// Handle responses
Multiplayer.Client.OnResponse += (message) => {
Terminal terminal = JsonUtility.FromJson(message.GetMessage);
// Process server response
};
4. Send Game Data
Synchronize game state with server over reliable TCP (queued automatically):
// Create command with game data
Terminal commands = Terminal.New()
.Next("set-game-data").Arg(JsonUtility.ToJson(playerData))
.Next("get-server-data");
// Send to server — queued if a response is still pending
Multiplayer.Client.Request(new Message(JsonUtility.ToJson(commands)));
5. Per-Frame State Sync
Send positions/transforms at 30-60 Hz over the unreliable UDP channel:
// Client: each frame Multiplayer.SendState(new Message(JsonUtility.ToJson(playerTransform))); // Server: apply + rebroadcast to all known clients Multiplayer.OnState += (IPEndPoint from, Message msg) => ApplyState(from, msg); Multiplayer.BroadcastState(new Message(JsonUtility.ToJson(worldSnapshot)));
6. Command Pattern
Use the terminal command system:
// Create commands with arguments
Command loginCmd = Command.New("login")
.Arg("username")
.Arg("password");
// Chain multiple commands
Terminal terminal = Terminal.New()
.Next("login").Arg("user").Arg("pass")
.Next("get-data")
.Next("set-data").Arg(jsonData);
Open License
Lan Multiplayer is released under the MIT No Attribution (MIT-0) license.
Use it freely for personal, educational, or commercial projects. No payment and no attribution are required.