class_ip.rst 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/3.6/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/3.6/doc/classes/IP.xml.
  6. .. _class_IP:
  7. IP
  8. ==
  9. **Inherits:** :ref:`Object<class_Object>`
  10. Internet protocol (IP) support functions such as DNS resolution.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. IP contains support functions for the Internet Protocol (IP). TCP/IP support is in different classes (see :ref:`StreamPeerTCP<class_StreamPeerTCP>` and :ref:`TCP_Server<class_TCP_Server>`). IP provides DNS hostname resolution support, both blocking and threaded.
  15. .. rst-class:: classref-reftable-group
  16. Methods
  17. -------
  18. .. table::
  19. :widths: auto
  20. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  21. | void | :ref:`clear_cache<class_IP_method_clear_cache>` **(** :ref:`String<class_String>` hostname="" **)** |
  22. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  23. | void | :ref:`erase_resolve_item<class_IP_method_erase_resolve_item>` **(** :ref:`int<class_int>` id **)** |
  24. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  25. | :ref:`Array<class_Array>` | :ref:`get_local_addresses<class_IP_method_get_local_addresses>` **(** **)** |const| |
  26. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  27. | :ref:`Array<class_Array>` | :ref:`get_local_interfaces<class_IP_method_get_local_interfaces>` **(** **)** |const| |
  28. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  29. | :ref:`String<class_String>` | :ref:`get_resolve_item_address<class_IP_method_get_resolve_item_address>` **(** :ref:`int<class_int>` id **)** |const| |
  30. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  31. | :ref:`Array<class_Array>` | :ref:`get_resolve_item_addresses<class_IP_method_get_resolve_item_addresses>` **(** :ref:`int<class_int>` id **)** |const| |
  32. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  33. | :ref:`ResolverStatus<enum_IP_ResolverStatus>` | :ref:`get_resolve_item_status<class_IP_method_get_resolve_item_status>` **(** :ref:`int<class_int>` id **)** |const| |
  34. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  35. | :ref:`String<class_String>` | :ref:`resolve_hostname<class_IP_method_resolve_hostname>` **(** :ref:`String<class_String>` host, :ref:`Type<enum_IP_Type>` ip_type=3 **)** |
  36. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | :ref:`Array<class_Array>` | :ref:`resolve_hostname_addresses<class_IP_method_resolve_hostname_addresses>` **(** :ref:`String<class_String>` host, :ref:`Type<enum_IP_Type>` ip_type=3 **)** |
  38. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | :ref:`int<class_int>` | :ref:`resolve_hostname_queue_item<class_IP_method_resolve_hostname_queue_item>` **(** :ref:`String<class_String>` host, :ref:`Type<enum_IP_Type>` ip_type=3 **)** |
  40. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. .. rst-class:: classref-section-separator
  42. ----
  43. .. rst-class:: classref-descriptions-group
  44. Enumerations
  45. ------------
  46. .. _enum_IP_ResolverStatus:
  47. .. rst-class:: classref-enumeration
  48. enum **ResolverStatus**:
  49. .. _class_IP_constant_RESOLVER_STATUS_NONE:
  50. .. rst-class:: classref-enumeration-constant
  51. :ref:`ResolverStatus<enum_IP_ResolverStatus>` **RESOLVER_STATUS_NONE** = ``0``
  52. DNS hostname resolver status: No status.
  53. .. _class_IP_constant_RESOLVER_STATUS_WAITING:
  54. .. rst-class:: classref-enumeration-constant
  55. :ref:`ResolverStatus<enum_IP_ResolverStatus>` **RESOLVER_STATUS_WAITING** = ``1``
  56. DNS hostname resolver status: Waiting.
  57. .. _class_IP_constant_RESOLVER_STATUS_DONE:
  58. .. rst-class:: classref-enumeration-constant
  59. :ref:`ResolverStatus<enum_IP_ResolverStatus>` **RESOLVER_STATUS_DONE** = ``2``
  60. DNS hostname resolver status: Done.
  61. .. _class_IP_constant_RESOLVER_STATUS_ERROR:
  62. .. rst-class:: classref-enumeration-constant
  63. :ref:`ResolverStatus<enum_IP_ResolverStatus>` **RESOLVER_STATUS_ERROR** = ``3``
  64. DNS hostname resolver status: Error.
  65. .. rst-class:: classref-item-separator
  66. ----
  67. .. _enum_IP_Type:
  68. .. rst-class:: classref-enumeration
  69. enum **Type**:
  70. .. _class_IP_constant_TYPE_NONE:
  71. .. rst-class:: classref-enumeration-constant
  72. :ref:`Type<enum_IP_Type>` **TYPE_NONE** = ``0``
  73. Address type: None.
  74. .. _class_IP_constant_TYPE_IPV4:
  75. .. rst-class:: classref-enumeration-constant
  76. :ref:`Type<enum_IP_Type>` **TYPE_IPV4** = ``1``
  77. Address type: Internet protocol version 4 (IPv4).
  78. .. _class_IP_constant_TYPE_IPV6:
  79. .. rst-class:: classref-enumeration-constant
  80. :ref:`Type<enum_IP_Type>` **TYPE_IPV6** = ``2``
  81. Address type: Internet protocol version 6 (IPv6).
  82. .. _class_IP_constant_TYPE_ANY:
  83. .. rst-class:: classref-enumeration-constant
  84. :ref:`Type<enum_IP_Type>` **TYPE_ANY** = ``3``
  85. Address type: Any.
  86. .. rst-class:: classref-section-separator
  87. ----
  88. .. rst-class:: classref-descriptions-group
  89. Constants
  90. ---------
  91. .. _class_IP_constant_RESOLVER_MAX_QUERIES:
  92. .. rst-class:: classref-constant
  93. **RESOLVER_MAX_QUERIES** = ``256``
  94. Maximum number of concurrent DNS resolver queries allowed, :ref:`RESOLVER_INVALID_ID<class_IP_constant_RESOLVER_INVALID_ID>` is returned if exceeded.
  95. .. _class_IP_constant_RESOLVER_INVALID_ID:
  96. .. rst-class:: classref-constant
  97. **RESOLVER_INVALID_ID** = ``-1``
  98. Invalid ID constant. Returned if :ref:`RESOLVER_MAX_QUERIES<class_IP_constant_RESOLVER_MAX_QUERIES>` is exceeded.
  99. .. rst-class:: classref-section-separator
  100. ----
  101. .. rst-class:: classref-descriptions-group
  102. Method Descriptions
  103. -------------------
  104. .. _class_IP_method_clear_cache:
  105. .. rst-class:: classref-method
  106. void **clear_cache** **(** :ref:`String<class_String>` hostname="" **)**
  107. Removes all of a ``hostname``'s cached references. If no ``hostname`` is given, all cached IP addresses are removed.
  108. .. rst-class:: classref-item-separator
  109. ----
  110. .. _class_IP_method_erase_resolve_item:
  111. .. rst-class:: classref-method
  112. void **erase_resolve_item** **(** :ref:`int<class_int>` id **)**
  113. Removes a given item ``id`` from the queue. This should be used to free a queue after it has completed to enable more queries to happen.
  114. .. rst-class:: classref-item-separator
  115. ----
  116. .. _class_IP_method_get_local_addresses:
  117. .. rst-class:: classref-method
  118. :ref:`Array<class_Array>` **get_local_addresses** **(** **)** |const|
  119. Returns all the user's current IPv4 and IPv6 addresses as an array.
  120. .. rst-class:: classref-item-separator
  121. ----
  122. .. _class_IP_method_get_local_interfaces:
  123. .. rst-class:: classref-method
  124. :ref:`Array<class_Array>` **get_local_interfaces** **(** **)** |const|
  125. Returns all network adapters as an array.
  126. Each adapter is a dictionary of the form:
  127. ::
  128. {
  129. "index": "1", # Interface index.
  130. "name": "eth0", # Interface name.
  131. "friendly": "Ethernet One", # A friendly name (might be empty).
  132. "addresses": ["192.168.1.101"], # An array of IP addresses associated to this interface.
  133. }
  134. .. rst-class:: classref-item-separator
  135. ----
  136. .. _class_IP_method_get_resolve_item_address:
  137. .. rst-class:: classref-method
  138. :ref:`String<class_String>` **get_resolve_item_address** **(** :ref:`int<class_int>` id **)** |const|
  139. Returns a queued hostname's IP address, given its queue ``id``. Returns an empty string on error or if resolution hasn't happened yet (see :ref:`get_resolve_item_status<class_IP_method_get_resolve_item_status>`).
  140. .. rst-class:: classref-item-separator
  141. ----
  142. .. _class_IP_method_get_resolve_item_addresses:
  143. .. rst-class:: classref-method
  144. :ref:`Array<class_Array>` **get_resolve_item_addresses** **(** :ref:`int<class_int>` id **)** |const|
  145. Return resolved addresses, or an empty array if an error happened or resolution didn't happen yet (see :ref:`get_resolve_item_status<class_IP_method_get_resolve_item_status>`).
  146. .. rst-class:: classref-item-separator
  147. ----
  148. .. _class_IP_method_get_resolve_item_status:
  149. .. rst-class:: classref-method
  150. :ref:`ResolverStatus<enum_IP_ResolverStatus>` **get_resolve_item_status** **(** :ref:`int<class_int>` id **)** |const|
  151. Returns a queued hostname's status as a :ref:`ResolverStatus<enum_IP_ResolverStatus>` constant, given its queue ``id``.
  152. .. rst-class:: classref-item-separator
  153. ----
  154. .. _class_IP_method_resolve_hostname:
  155. .. rst-class:: classref-method
  156. :ref:`String<class_String>` **resolve_hostname** **(** :ref:`String<class_String>` host, :ref:`Type<enum_IP_Type>` ip_type=3 **)**
  157. Returns a given hostname's IPv4 or IPv6 address when resolved (blocking-type method). The address type returned depends on the :ref:`Type<enum_IP_Type>` constant given as ``ip_type``.
  158. .. rst-class:: classref-item-separator
  159. ----
  160. .. _class_IP_method_resolve_hostname_addresses:
  161. .. rst-class:: classref-method
  162. :ref:`Array<class_Array>` **resolve_hostname_addresses** **(** :ref:`String<class_String>` host, :ref:`Type<enum_IP_Type>` ip_type=3 **)**
  163. Resolves a given hostname in a blocking way. Addresses are returned as an :ref:`Array<class_Array>` of IPv4 or IPv6 depending on ``ip_type``.
  164. .. rst-class:: classref-item-separator
  165. ----
  166. .. _class_IP_method_resolve_hostname_queue_item:
  167. .. rst-class:: classref-method
  168. :ref:`int<class_int>` **resolve_hostname_queue_item** **(** :ref:`String<class_String>` host, :ref:`Type<enum_IP_Type>` ip_type=3 **)**
  169. Creates a queue item to resolve a hostname to an IPv4 or IPv6 address depending on the :ref:`Type<enum_IP_Type>` constant given as ``ip_type``. Returns the queue ID if successful, or :ref:`RESOLVER_INVALID_ID<class_IP_constant_RESOLVER_INVALID_ID>` on error.
  170. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  171. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  172. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  173. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`