🐾PurrNet Docs
Advanced

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.

ParameterTypeDefaultDescription
UDP (KcpTransport)UDP / KCPAnyDefault transport. Fast, reliable-optional channels over raw UDP. Best for PC and mobile games with low latency requirements.
WebSocketTCP / WSWebGLRequired for WebGL builds. Also useful for browser-based tools, admin panels, and firewalled corporate networks that block UDP.
Steam (Facepunch / Mirror)Steam P2PSteamRoutes traffic through Valve's relay network. No port forwarding needed. Requires Steamworks SDK and a Steam app ID.
EOS (Epic Online Services)EOS P2PEpic GamesRoutes through Epic's relay network. Works on PC, console, and mobile. Requires EOS SDK and free developer account.
CompositeAuto-selectMixed platformsContainer that holds multiple transports. Automatically picks the best available one per platform at startup.
Local (Loopback)In-processEditor testingConnects server and client in the same process with no real network. Zero-latency. Ideal for automated testing and quick iteration.
Purr (Relay)UDP relayDevelopmentFree 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.

NetworkManagerSetup.cs
// 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:

KcpTransportSettings.cs
// 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.

PurrRelayQuickStart.cs
// 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

During early development you rarely want to deal with port forwarding. The Purr Transport lets you test multiplayer between two machines instantly at zero cost. Switch to KcpTransport (or CompositeTransport) before going to production.

Steam transport requires Steamworks

SteamTransport requires the Facepunch.Steamworks or Mirror Steamworks package and a valid Steam app ID. The Steamworks client must be running on both machines. It is not available in WebGL or console builds. Use CompositeTransport with KCP as a fallback.

WebSocket has higher latency than UDP

WebSocket runs over TCP, which adds head-of-line blocking. For real-time games, prefer UDP (KCP) wherever possible and only use WebSocket as a fallback for WebGL or heavily firewalled environments.