Ali Şahan Yalçın
DocsNetworking

More features

Networking

Sending data between players over Steam's relay network.

Steam's networking carries game data between players without either of them needing a public IP. Traffic can route through Steam's relay network, which hides player IP addresses and gets through NAT that direct connections cannot.

This sits alongside Unreal's replication rather than replacing it.

Hosting and connecting

NodeWhat it does
Start Listening P2PAccept peer to peer connections
Connect To PeerConnect to a host by Steam ID
Start Listening IPAccept ordinary IP connections, for a dedicated server or LAN
Connect To AddressConnect by address, for example 1.2.3.4:27015
Stop ListeningStop accepting new connections. Existing ones stay open.

Prefer the P2P nodes for player hosted games. The IP nodes listen on a real socket, so player addresses are visible to each other and NAT traversal becomes your problem instead of Steam's.

A typical host flow

  • Start Listening P2P
  • On On Incoming Connection, call Accept Connection, or Close Connection to refuse
  • On On Connected, the peer is usable
  • Send Bytes or Send String, and handle On Message Received
  • A client just calls Connect To Peer with the host's Steam ID and waits for On Connected.

    Relay readiness

    Relay access is requested automatically at startup and takes a few seconds to become ready. Get Relay Status reports progress. Connections started before it is Current simply take longer rather than failing.

    Ping without connecting

    Get Local Ping Location returns an opaque token describing where this machine sits in Steam's relay network. It is not geography and not an IP address, which is what makes it safe to publish.

    Put it in your lobby data and any other player can estimate their ping to you without either of you connecting first:

  • Estimate Ping To Location from this machine to a published location.
  • Estimate Ping Between Locations between two published locations, neither of which needs to be you.
  • That is how a lobby browser sorts by latency honestly. Check Is Ping Data Ready first, since Steam needs a few seconds after startup to measure.

    Connection lanes

    One connection normally means one queue, so a large reliable message blocks everything behind it until it finishes.

    Configure Connection Lanes splits a connection into independent priority queues, so a 4 MB asset transfer stops delaying the position updates travelling beside it. Send Bytes On Lane chooses the queue.

    Lower priority numbers send first. Lanes sharing a priority split bandwidth by weight.

    Configure lanes right after the connection opens and before sending anything. Steam will not shrink the lane count afterwards.