mirror of
https://github.com/godotengine/godot-docs.git
synced 2026-01-05 22:09:56 +03:00
146 lines
9.1 KiB
ReStructuredText
146 lines
9.1 KiB
ReStructuredText
:github_url: hide
|
|
|
|
.. Generated automatically by doc/tools/makerst.py in Godot's source tree.
|
|
.. DO NOT EDIT THIS FILE, but the PacketPeerUDP.xml source instead.
|
|
.. The source is found in doc/classes or modules/<name>/doc_classes.
|
|
|
|
.. _class_PacketPeerUDP:
|
|
|
|
PacketPeerUDP
|
|
=============
|
|
|
|
**Inherits:** :ref:`PacketPeer<class_PacketPeer>` **<** :ref:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
|
|
|
|
**Category:** Core
|
|
|
|
Brief Description
|
|
-----------------
|
|
|
|
UDP packet peer.
|
|
|
|
Methods
|
|
-------
|
|
|
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`close<class_PacketPeerUDP_method_close>` **(** **)** |
|
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`String<class_String>` | :ref:`get_packet_ip<class_PacketPeerUDP_method_get_packet_ip>` **(** **)** const |
|
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`int<class_int>` | :ref:`get_packet_port<class_PacketPeerUDP_method_get_packet_port>` **(** **)** const |
|
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`is_listening<class_PacketPeerUDP_method_is_listening>` **(** **)** const |
|
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Error<enum_@GlobalScope_Error>` | :ref:`join_multicast_group<class_PacketPeerUDP_method_join_multicast_group>` **(** :ref:`String<class_String>` multicast_address, :ref:`String<class_String>` interface_name **)** |
|
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Error<enum_@GlobalScope_Error>` | :ref:`leave_multicast_group<class_PacketPeerUDP_method_leave_multicast_group>` **(** :ref:`String<class_String>` multicast_address, :ref:`String<class_String>` interface_name **)** |
|
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Error<enum_@GlobalScope_Error>` | :ref:`listen<class_PacketPeerUDP_method_listen>` **(** :ref:`int<class_int>` port, :ref:`String<class_String>` bind_address="*", :ref:`int<class_int>` recv_buf_size=65536 **)** |
|
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`set_broadcast_enabled<class_PacketPeerUDP_method_set_broadcast_enabled>` **(** :ref:`bool<class_bool>` enabled **)** |
|
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Error<enum_@GlobalScope_Error>` | :ref:`set_dest_address<class_PacketPeerUDP_method_set_dest_address>` **(** :ref:`String<class_String>` host, :ref:`int<class_int>` port **)** |
|
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Error<enum_@GlobalScope_Error>` | :ref:`wait<class_PacketPeerUDP_method_wait>` **(** **)** |
|
|
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
Description
|
|
-----------
|
|
|
|
UDP packet peer. Can be used to send raw UDP packets as well as :ref:`Variant<class_Variant>`\ s.
|
|
|
|
Method Descriptions
|
|
-------------------
|
|
|
|
.. _class_PacketPeerUDP_method_close:
|
|
|
|
- void **close** **(** **)**
|
|
|
|
Closes the UDP socket the ``PacketPeerUDP`` is currently listening on.
|
|
|
|
----
|
|
|
|
.. _class_PacketPeerUDP_method_get_packet_ip:
|
|
|
|
- :ref:`String<class_String>` **get_packet_ip** **(** **)** const
|
|
|
|
Returns the IP of the remote peer that sent the last packet(that was received with :ref:`PacketPeer.get_packet<class_PacketPeer_method_get_packet>` or :ref:`PacketPeer.get_var<class_PacketPeer_method_get_var>`).
|
|
|
|
----
|
|
|
|
.. _class_PacketPeerUDP_method_get_packet_port:
|
|
|
|
- :ref:`int<class_int>` **get_packet_port** **(** **)** const
|
|
|
|
Returns the port of the remote peer that sent the last packet(that was received with :ref:`PacketPeer.get_packet<class_PacketPeer_method_get_packet>` or :ref:`PacketPeer.get_var<class_PacketPeer_method_get_var>`).
|
|
|
|
----
|
|
|
|
.. _class_PacketPeerUDP_method_is_listening:
|
|
|
|
- :ref:`bool<class_bool>` **is_listening** **(** **)** const
|
|
|
|
Returns whether this ``PacketPeerUDP`` is listening.
|
|
|
|
----
|
|
|
|
.. _class_PacketPeerUDP_method_join_multicast_group:
|
|
|
|
- :ref:`Error<enum_@GlobalScope_Error>` **join_multicast_group** **(** :ref:`String<class_String>` multicast_address, :ref:`String<class_String>` interface_name **)**
|
|
|
|
Joins the multicast group specified by ``multicast_address`` using the interface identified by ``interface_name``.
|
|
|
|
You can join the same multicast group with multiple interfaces. Use :ref:`IP.get_local_interfaces<class_IP_method_get_local_interfaces>` to know which are available.
|
|
|
|
Note: Some Android devices might require the ``CHANGE_WIFI_MULTICAST_STATE`` permission for multicast to work.
|
|
|
|
----
|
|
|
|
.. _class_PacketPeerUDP_method_leave_multicast_group:
|
|
|
|
- :ref:`Error<enum_@GlobalScope_Error>` **leave_multicast_group** **(** :ref:`String<class_String>` multicast_address, :ref:`String<class_String>` interface_name **)**
|
|
|
|
Removes the interface identified by ``interface_name`` from the multicast group specified by ``multicast_address``.
|
|
|
|
----
|
|
|
|
.. _class_PacketPeerUDP_method_listen:
|
|
|
|
- :ref:`Error<enum_@GlobalScope_Error>` **listen** **(** :ref:`int<class_int>` port, :ref:`String<class_String>` bind_address="*", :ref:`int<class_int>` recv_buf_size=65536 **)**
|
|
|
|
Makes this ``PacketPeerUDP`` listen on the ``port`` binding to ``bind_address`` with a buffer size ``recv_buf_size``.
|
|
|
|
If ``bind_address`` is set to ``"*"`` (default), the peer will listen on all available addresses (both IPv4 and IPv6).
|
|
|
|
If ``bind_address`` is set to ``"0.0.0.0"`` (for IPv4) or ``"::"`` (for IPv6), the peer will listen on all available addresses matching that IP type.
|
|
|
|
If ``bind_address`` is set to any valid address (e.g. ``"192.168.1.101"``, ``"::1"``, etc), the peer will only listen on the interface with that addresses (or fail if no interface with the given address exists).
|
|
|
|
----
|
|
|
|
.. _class_PacketPeerUDP_method_set_broadcast_enabled:
|
|
|
|
- void **set_broadcast_enabled** **(** :ref:`bool<class_bool>` enabled **)**
|
|
|
|
Enable or disable sending of broadcast packets (e.g. ``set_dest_address("255.255.255.255", 4343)``. This option is disabled by default.
|
|
|
|
Note: Some Android devices might require the ``CHANGE_WIFI_MULTICAST_STATE`` permission and this option to be enabled to receive broadcast packets too.
|
|
|
|
----
|
|
|
|
.. _class_PacketPeerUDP_method_set_dest_address:
|
|
|
|
- :ref:`Error<enum_@GlobalScope_Error>` **set_dest_address** **(** :ref:`String<class_String>` host, :ref:`int<class_int>` port **)**
|
|
|
|
Sets the destination address and port for sending packets and variables. A hostname will be resolved using DNS if needed.
|
|
|
|
Note: :ref:`set_broadcast_enabled<class_PacketPeerUDP_method_set_broadcast_enabled>` must be enabled before sending packets to a broadcast address (e.g. ``255.255.255.255``).
|
|
|
|
----
|
|
|
|
.. _class_PacketPeerUDP_method_wait:
|
|
|
|
- :ref:`Error<enum_@GlobalScope_Error>` **wait** **(** **)**
|
|
|
|
Waits for a packet to arrive on the listening port. See :ref:`listen<class_PacketPeerUDP_method_listen>`.
|
|
|