Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

PacketPeer

Inherits: RefCounted < Object

Inherited By: ENetPacketPeer, MultiplayerPeer, PacketPeerDTLS, PacketPeerExtension, PacketPeerStream, PacketPeerUDP, WebRTCDataChannel, WebSocketPeer

Abstraction and base class for packet-based protocols.

Description

PacketPeer is an abstraction and base class for packet-based protocols (such as UDP). It provides an API for sending and receiving packets both as raw data or variables. This makes it easy to transfer data over a protocol, without having to encode data as low-level bytes or having to worry about network ordering.

Note: When exporting to Android, make sure to enable the INTERNET permission in the Android export preset before exporting the project or using one-click deploy. Otherwise, network communication of any kind will be blocked by Android.

Properties

int

encode_buffer_max_size

8388608

Methods

int

get_available_packet_count ( ) const

PackedByteArray

get_packet ( )

Error

get_packet_error ( ) const

Variant

get_var ( bool allow_objects=false )

Error

put_packet ( PackedByteArray buffer )

Error

put_var ( Variant var, bool full_objects=false )


Property Descriptions

int encode_buffer_max_size = 8388608

  • void set_encode_buffer_max_size ( int value )