Godot provides a multi-layered networking stack ranging from low-level TCP/UDP/HTTP protocols to a high-level "Scene Replication" system. The architecture is designed to abstract the underlying transport layer, allowing developers to swap between ENet, WebSockets, or WebRTC without rewriting game logic.
The high-level multiplayer system is built directly into the Node hierarchy and managed by the MultiplayerAPI. It provides a server-authoritative model by default but supports various topologies. The system relies on NodePath consistency across connected peers to identify which objects should receive data or execute commands.
MultiplayerAPI that handles the heavy lifting of RPCs and replication modules/multiplayer/scene_multiplayer.cpp31rpc method on any Node modules/multiplayer/scene_rpc_interface.cpp31MultiplayerSpawner modules/multiplayer/multiplayer_spawner.cpp31 and MultiplayerSynchronizer modules/multiplayer/multiplayer_synchronizer.cpp31Sources: modules/multiplayer/scene_multiplayer.h40-41 modules/multiplayer/scene_multiplayer.cpp31 modules/multiplayer/scene_rpc_interface.cpp31 modules/multiplayer/multiplayer_spawner.cpp31 modules/multiplayer/multiplayer_synchronizer.cpp31 modules/multiplayer/scene_replication_interface.cpp129-154
For details on replication and RPC configuration, see High-Level Multiplayer.
Godot abstracts low-level networking through the MultiplayerPeer class. This allows the high-level system to remain agnostic of the specific protocol used (e.g., UDP vs. WebSockets).
HTTPClient and HTTPRequest for RESTful API interactions, such as fetching player profiles or leaderboards core/io/http_client.h37Sources: modules/multiplayer/scene_multiplayer.h40-41 core/io/http_client.h37 modules/multiplayer/scene_multiplayer.cpp73-89
For details on configuring specific protocols and handling low-level packets, see Network Transport Layer.
Godot provides several classes for direct low-level network communication, allowing fine-grained control over data transmission via PacketPeer and StreamPeer implementations.
PacketPeerUDP: Handles connectionless UDP packets. It supports multicast groups and broadcast.StreamPeerTCP: Provides a stream-oriented connection over TCP.HTTPClient and HTTPRequestThe HTTP system allows for web communication, supporting both raw management and node-based automation.
HTTPClient: A low-level, RefCounted client for HTTP/1.1 core/io/http_client.h37 It defines common HTTP methods such as GET, POST, and PUT core/io/http_client.cpp35-45
connect_to_host(host, port, tls_options): Initiates connection core/io/http_client.cpp143poll(): Updates the internal state machine core/io/http_client.cpp164HTTPRequest: A Node wrapper for HTTPClient that simplifies common tasks like downloading files to disk scene/main/http_request.h86-89 and handling redirects automatically scene/main/http_request.h102-106
request(): Parses URLs and manages the client lifecycle scene/main/http_request.cpp109-122cancel_request(): Properly cleans up threads and files scene/main/http_request.cpp192-216Sources: scene/main/http_request.cpp42-44 core/io/http_client.cpp143-147 scene/main/http_request.h179-180 core/io/http_client.h168-169
Godot uses mbedTLS as the backend for secure communication. TLSOptions objects are used to configure how clients and servers verify identities.
TLSOptions::client(): Returns a default client configuration for secure HTTPS connections.TLSOptions::client_unsafe(): Allows connecting to servers with self-signed certificates (not recommended for production).Sources: core/io/http_client.cpp35-45 scene/main/http_request.cpp109-122 core/io/http_client.h37 scene/main/http_request.h86-89 scene/main/http_request.h102-106 scene/main/http_request.cpp192-216
Refresh this wiki
This wiki was recently refreshed. Please wait 4 days to refresh again.