Transports
PurrNet is transport-agnostic. Swap the underlying protocol by dragging a different Transport component onto your NetworkManager. CompositeTransport lets you bundle multiple transports and auto-select the best one per platform.
Available transports
Each transport is a component that lives on the same GameObject as your NetworkManager. PurrNet reads whichever transport component is active at startup. Add only one active transport at a time, or use CompositeTransport to bundle several.
| Parameter | Type | Default | Description |
|---|---|---|---|
UDP (KcpTransport) | UDP / KCP | Any | Default transport. Fast, reliable-optional channels over raw UDP. Best for PC and mobile games with low latency requirements. |
WebSocket | TCP / WS | WebGL | Required for WebGL builds. Also useful for browser-based tools, admin panels, and firewalled corporate networks that block UDP. |
Steam (Facepunch / Mirror) | Steam P2P | Steam | Routes traffic through Valve's relay network. No port forwarding needed. Requires Steamworks SDK and a Steam app ID. |
EOS (Epic Online Services) | EOS P2P | Epic Games | Routes through Epic's relay network. Works on PC, console, and mobile. Requires EOS SDK and free developer account. |
Composite | Auto-select | Mixed platforms | Container that holds multiple transports. Automatically picks the best available one per platform at startup. |
Local (Loopback) | In-process | Editor testing | Connects server and client in the same process with no real network. Zero-latency. Ideal for automated testing and quick iteration. |
Purr (Relay) | UDP relay | Development | Free relay transport hosted by the PurrNet team. No setup required. Intended for development and small-scale testing — not production. |
CompositeTransport — multi-platform setup
CompositeTransport holds a priority-ordered list of child transports. At startup, it tests each in order and activates the first one that is available on the current platform. This lets you ship a single build that uses UDP on PC, WebSocket on WebGL, and Steam P2P on Steam Deck without any #if guards in your code.
// CompositeTransport configuration — set up in the Inspector, not in code.
// Priority order (first available wins):
// 1. SteamTransport — active if Steamworks is initialised
// 2. KcpTransport — active on PC / mobile / console
// 3. WebSocketTransport — active on WebGL
//
// You don't need any code; just add the components and set the priority list
// on the CompositeTransport component in the Inspector.
// If you DO need runtime transport switching (e.g. fallback on connection failure):
using PurrNet;
using UnityEngine;
public class TransportSelector : MonoBehaviour
{
[SerializeField] private NetworkManager _networkManager;
[SerializeField] private CompositeTransport _composite;
public void ForceWebSocket()
{
// Override platform detection — useful for troubleshooting
_composite.ForceTransport<WebSocketTransport>();
}
}Configuring the KCP (UDP) transport
The default UDP transport exposes several Inspector fields. Common production settings:
// These are Inspector properties on the KcpTransport component.
// No code is required — configure them in the Unity Inspector.
//
// Port: 7777 — UDP port to listen on (server) / connect to (client)
// Max Connections: 100 — hard cap; clients above this are rejected
// NoDelay: true — disable Nagle's algorithm for lower latency
// Interval (ms): 10 — internal KCP tick interval; lower = lower latency, higher CPU
// FastResend: 2 — retransmit after N duplicate ACKs without waiting for timeout
// CongestionWindow: false — disable congestion window for game traffic patterns
//
// For a dedicated server you will also want:
// - IPv4+IPv6 dual-stack: enable DualMode in the transport
// - Headless mode: set Application.targetFrameRate = 60 in a server bootstrap script
// Runtime address override (e.g. from a matchmaker response):
using PurrNet;
using UnityEngine;
public class MatchmakerConnector : MonoBehaviour
{
[SerializeField] private NetworkManager _networkManager;
[SerializeField] private KcpTransport _transport;
public void ConnectToServer(string ip, ushort port)
{
_transport.port = port;
_transport.address = ip;
_networkManager.StartClient();
}
}Purr Relay — quick dev testing
The Purr Transport connects through the free PurrNet relay, so two developers can test together without port forwarding or cloud servers. Add the PurrTransport component to your NetworkManager, enable it, and connect using the room code shown in the Editor console.
// No code needed for basic usage — just:
// 1. Add PurrTransport component to the NetworkManager GameObject
// 2. Call networkManager.StartHost() from your menu UI
// 3. Share the room code from the console with your test partner
// 4. They add the code in their client UI and call networkManager.StartClient()
// If you want to display the room code in UI:
using PurrNet;
using TMPro;
using UnityEngine;
public class PurrRelayUI : MonoBehaviour
{
[SerializeField] private PurrTransport _purrTransport;
[SerializeField] private TextMeshProUGUI _roomCodeLabel;
private void OnEnable()
{
_purrTransport.onRoomCreated += code => _roomCodeLabel.text = $"Room: {code}";
}
private void OnDisable()
{
_purrTransport.onRoomCreated -= code => _roomCodeLabel.text = $"Room: {code}";
}
}Use Purr Transport for free development relay
Steam transport requires Steamworks
WebSocket has higher latency than UDP