.. Generated automatically by doc/tools/makerst.py in Godot's source tree.
.. DO NOT EDIT THIS FILE, but the PacketPeer.xml source instead.
.. The source is found in doc/classes or modules/<name>/doc_classes.

.. _class_PacketPeer:

PacketPeer
==========

**Inherits:** :ref:`Reference<class_reference>` **<** :ref:`Object<class_object>`

**Inherited By:** :ref:`PacketPeerStream<class_packetpeerstream>`, :ref:`PacketPeerUDP<class_packetpeerudp>`, :ref:`NetworkedMultiplayerPeer<class_networkedmultiplayerpeer>`

**Category:** Core

Brief Description
-----------------

Abstraction and base class for packet-based protocols.

Member Functions
----------------

+--------------------------------------------+-------------------------------------------------------------------------------------------------------------+
| :ref:`int<class_int>`                      | :ref:`get_available_packet_count<class_PacketPeer_get_available_packet_count>` **(** **)** const            |
+--------------------------------------------+-------------------------------------------------------------------------------------------------------------+
| :ref:`PoolByteArray<class_poolbytearray>`  | :ref:`get_packet<class_PacketPeer_get_packet>` **(** **)**                                                  |
+--------------------------------------------+-------------------------------------------------------------------------------------------------------------+
| :ref:`int<class_int>`                      | :ref:`get_packet_error<class_PacketPeer_get_packet_error>` **(** **)** const                                |
+--------------------------------------------+-------------------------------------------------------------------------------------------------------------+
| :ref:`Variant<class_variant>`              | :ref:`get_var<class_PacketPeer_get_var>` **(** **)**                                                        |
+--------------------------------------------+-------------------------------------------------------------------------------------------------------------+
| :ref:`int<class_int>`                      | :ref:`put_packet<class_PacketPeer_put_packet>` **(** :ref:`PoolByteArray<class_poolbytearray>` buffer **)** |
+--------------------------------------------+-------------------------------------------------------------------------------------------------------------+
| :ref:`int<class_int>`                      | :ref:`put_var<class_PacketPeer_put_var>` **(** :ref:`Variant<class_variant>` var **)**                      |
+--------------------------------------------+-------------------------------------------------------------------------------------------------------------+

Member Variables
----------------

  .. _class_PacketPeer_allow_object_decoding:

- :ref:`bool<class_bool>` **allow_object_decoding**


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.

Member Function Description
---------------------------

.. _class_PacketPeer_get_available_packet_count:

- :ref:`int<class_int>` **get_available_packet_count** **(** **)** const

Return the number of packets currently available in the ring-buffer.

.. _class_PacketPeer_get_packet:

- :ref:`PoolByteArray<class_poolbytearray>` **get_packet** **(** **)**

Get a raw packet.

.. _class_PacketPeer_get_packet_error:

- :ref:`int<class_int>` **get_packet_error** **(** **)** const

Return the error state of the last packet received (via :ref:`get_packet<class_PacketPeer_get_packet>` and :ref:`get_var<class_PacketPeer_get_var>`).

.. _class_PacketPeer_get_var:

- :ref:`Variant<class_variant>` **get_var** **(** **)**

Get a Variant.

.. _class_PacketPeer_put_packet:

- :ref:`int<class_int>` **put_packet** **(** :ref:`PoolByteArray<class_poolbytearray>` buffer **)**

Send a raw packet.

.. _class_PacketPeer_put_var:

- :ref:`int<class_int>` **put_var** **(** :ref:`Variant<class_variant>` var **)**

Send a Variant as a packet.


