class_packetpeerudp.rst 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the PacketPeerUDP.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_PacketPeerUDP:
  6. PacketPeerUDP
  7. =============
  8. **Inherits:** :ref:`PacketPeer<class_PacketPeer>` **<** :ref:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
  9. **Category:** Core
  10. Brief Description
  11. -----------------
  12. UDP packet peer.
  13. Methods
  14. -------
  15. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  16. | void | :ref:`close<class_PacketPeerUDP_method_close>` **(** **)** |
  17. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  18. | :ref:`String<class_String>` | :ref:`get_packet_ip<class_PacketPeerUDP_method_get_packet_ip>` **(** **)** const |
  19. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  20. | :ref:`int<class_int>` | :ref:`get_packet_port<class_PacketPeerUDP_method_get_packet_port>` **(** **)** const |
  21. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  22. | :ref:`bool<class_bool>` | :ref:`is_listening<class_PacketPeerUDP_method_is_listening>` **(** **)** const |
  23. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  24. | :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 **)** |
  25. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  26. | :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 **)** |
  27. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  28. | :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 **)** |
  29. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  30. | :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 **)** |
  31. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  32. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`wait<class_PacketPeerUDP_method_wait>` **(** **)** |
  33. +---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  34. Description
  35. -----------
  36. UDP packet peer. Can be used to send raw UDP packets as well as :ref:`Variant<class_Variant>`\ s.
  37. Method Descriptions
  38. -------------------
  39. .. _class_PacketPeerUDP_method_close:
  40. - void **close** **(** **)**
  41. Closes the UDP socket the ``PacketPeerUDP`` is currently listening on.
  42. .. _class_PacketPeerUDP_method_get_packet_ip:
  43. - :ref:`String<class_String>` **get_packet_ip** **(** **)** const
  44. 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>`).
  45. .. _class_PacketPeerUDP_method_get_packet_port:
  46. - :ref:`int<class_int>` **get_packet_port** **(** **)** const
  47. 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>`).
  48. .. _class_PacketPeerUDP_method_is_listening:
  49. - :ref:`bool<class_bool>` **is_listening** **(** **)** const
  50. Returns whether this ``PacketPeerUDP`` is listening.
  51. .. _class_PacketPeerUDP_method_join_multicast_group:
  52. - :ref:`Error<enum_@GlobalScope_Error>` **join_multicast_group** **(** :ref:`String<class_String>` multicast_address, :ref:`String<class_String>` interface_name **)**
  53. Joins the multicast group specified by ``multicast_address`` using the interface identified by ``interface_name``.
  54. 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.
  55. .. _class_PacketPeerUDP_method_leave_multicast_group:
  56. - :ref:`Error<enum_@GlobalScope_Error>` **leave_multicast_group** **(** :ref:`String<class_String>` multicast_address, :ref:`String<class_String>` interface_name **)**
  57. Removes the interface identified by ``interface_name`` from the multicast group specified by ``multicast_address``.
  58. .. _class_PacketPeerUDP_method_listen:
  59. - :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 **)**
  60. Makes this ``PacketPeerUDP`` listen on the ``port`` binding to ``bind_address`` with a buffer size ``recv_buf_size``.
  61. If ``bind_address`` is set to ``"*"`` (default), the peer will listen on all available addresses (both IPv4 and IPv6).
  62. 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.
  63. 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).
  64. .. _class_PacketPeerUDP_method_set_dest_address:
  65. - :ref:`Error<enum_@GlobalScope_Error>` **set_dest_address** **(** :ref:`String<class_String>` host, :ref:`int<class_int>` port **)**
  66. Sets the destination address and port for sending packets and variables. A hostname will be resolved using DNS if needed.
  67. .. _class_PacketPeerUDP_method_wait:
  68. - :ref:`Error<enum_@GlobalScope_Error>` **wait** **(** **)**
  69. Waits for a packet to arrive on the listening port. See :ref:`listen<class_PacketPeerUDP_method_listen>`.