class_enetconnection.rst 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  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/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/modules/enet/doc_classes/ENetConnection.xml.
  6. .. _class_ENetConnection:
  7. ENetConnection
  8. ==============
  9. **Inherits:** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
  10. A wrapper class for an `ENetHost <http://enet.bespin.org/group__host.html>`__.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. ENet's purpose is to provide a relatively thin, simple and robust network communication layer on top of UDP (User Datagram Protocol).
  15. .. rst-class:: classref-introduction-group
  16. Tutorials
  17. ---------
  18. - `API documentation on the ENet website <http://enet.bespin.org/usergroup0.html>`__
  19. .. rst-class:: classref-reftable-group
  20. Methods
  21. -------
  22. .. table::
  23. :widths: auto
  24. +--------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  25. | |void| | :ref:`bandwidth_limit<class_ENetConnection_method_bandwidth_limit>`\ (\ in_bandwidth\: :ref:`int<class_int>` = 0, out_bandwidth\: :ref:`int<class_int>` = 0\ ) |
  26. +--------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  27. | |void| | :ref:`broadcast<class_ENetConnection_method_broadcast>`\ (\ channel\: :ref:`int<class_int>`, packet\: :ref:`PackedByteArray<class_PackedByteArray>`, flags\: :ref:`int<class_int>`\ ) |
  28. +--------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  29. | |void| | :ref:`channel_limit<class_ENetConnection_method_channel_limit>`\ (\ limit\: :ref:`int<class_int>`\ ) |
  30. +--------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  31. | |void| | :ref:`compress<class_ENetConnection_method_compress>`\ (\ mode\: :ref:`CompressionMode<enum_ENetConnection_CompressionMode>`\ ) |
  32. +--------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  33. | :ref:`ENetPacketPeer<class_ENetPacketPeer>` | :ref:`connect_to_host<class_ENetConnection_method_connect_to_host>`\ (\ address\: :ref:`String<class_String>`, port\: :ref:`int<class_int>`, channels\: :ref:`int<class_int>` = 0, data\: :ref:`int<class_int>` = 0\ ) |
  34. +--------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  35. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`create_host<class_ENetConnection_method_create_host>`\ (\ max_peers\: :ref:`int<class_int>` = 32, max_channels\: :ref:`int<class_int>` = 0, in_bandwidth\: :ref:`int<class_int>` = 0, out_bandwidth\: :ref:`int<class_int>` = 0\ ) |
  36. +--------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`create_host_bound<class_ENetConnection_method_create_host_bound>`\ (\ bind_address\: :ref:`String<class_String>`, bind_port\: :ref:`int<class_int>`, max_peers\: :ref:`int<class_int>` = 32, max_channels\: :ref:`int<class_int>` = 0, in_bandwidth\: :ref:`int<class_int>` = 0, out_bandwidth\: :ref:`int<class_int>` = 0\ ) |
  38. +--------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | |void| | :ref:`destroy<class_ENetConnection_method_destroy>`\ (\ ) |
  40. +--------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`dtls_client_setup<class_ENetConnection_method_dtls_client_setup>`\ (\ hostname\: :ref:`String<class_String>`, client_options\: :ref:`TLSOptions<class_TLSOptions>` = null\ ) |
  42. +--------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`dtls_server_setup<class_ENetConnection_method_dtls_server_setup>`\ (\ server_options\: :ref:`TLSOptions<class_TLSOptions>`\ ) |
  44. +--------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | |void| | :ref:`flush<class_ENetConnection_method_flush>`\ (\ ) |
  46. +--------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | :ref:`int<class_int>` | :ref:`get_local_port<class_ENetConnection_method_get_local_port>`\ (\ ) |const| |
  48. +--------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | :ref:`int<class_int>` | :ref:`get_max_channels<class_ENetConnection_method_get_max_channels>`\ (\ ) |const| |
  50. +--------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | :ref:`Array<class_Array>`\[:ref:`ENetPacketPeer<class_ENetPacketPeer>`\] | :ref:`get_peers<class_ENetConnection_method_get_peers>`\ (\ ) |
  52. +--------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | :ref:`float<class_float>` | :ref:`pop_statistic<class_ENetConnection_method_pop_statistic>`\ (\ statistic\: :ref:`HostStatistic<enum_ENetConnection_HostStatistic>`\ ) |
  54. +--------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  55. | |void| | :ref:`refuse_new_connections<class_ENetConnection_method_refuse_new_connections>`\ (\ refuse\: :ref:`bool<class_bool>`\ ) |
  56. +--------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  57. | :ref:`Array<class_Array>` | :ref:`service<class_ENetConnection_method_service>`\ (\ timeout\: :ref:`int<class_int>` = 0\ ) |
  58. +--------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  59. | |void| | :ref:`socket_send<class_ENetConnection_method_socket_send>`\ (\ destination_address\: :ref:`String<class_String>`, destination_port\: :ref:`int<class_int>`, packet\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) |
  60. +--------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  61. .. rst-class:: classref-section-separator
  62. ----
  63. .. rst-class:: classref-descriptions-group
  64. Enumerations
  65. ------------
  66. .. _enum_ENetConnection_CompressionMode:
  67. .. rst-class:: classref-enumeration
  68. enum **CompressionMode**: :ref:`🔗<enum_ENetConnection_CompressionMode>`
  69. .. _class_ENetConnection_constant_COMPRESS_NONE:
  70. .. rst-class:: classref-enumeration-constant
  71. :ref:`CompressionMode<enum_ENetConnection_CompressionMode>` **COMPRESS_NONE** = ``0``
  72. No compression. This uses the most bandwidth, but has the upside of requiring the fewest CPU resources. This option may also be used to make network debugging using tools like Wireshark easier.
  73. .. _class_ENetConnection_constant_COMPRESS_RANGE_CODER:
  74. .. rst-class:: classref-enumeration-constant
  75. :ref:`CompressionMode<enum_ENetConnection_CompressionMode>` **COMPRESS_RANGE_CODER** = ``1``
  76. ENet's built-in range encoding. Works well on small packets, but is not the most efficient algorithm on packets larger than 4 KB.
  77. .. _class_ENetConnection_constant_COMPRESS_FASTLZ:
  78. .. rst-class:: classref-enumeration-constant
  79. :ref:`CompressionMode<enum_ENetConnection_CompressionMode>` **COMPRESS_FASTLZ** = ``2``
  80. `FastLZ <https://fastlz.org/>`__ compression. This option uses less CPU resources compared to :ref:`COMPRESS_ZLIB<class_ENetConnection_constant_COMPRESS_ZLIB>`, at the expense of using more bandwidth.
  81. .. _class_ENetConnection_constant_COMPRESS_ZLIB:
  82. .. rst-class:: classref-enumeration-constant
  83. :ref:`CompressionMode<enum_ENetConnection_CompressionMode>` **COMPRESS_ZLIB** = ``3``
  84. `Zlib <https://www.zlib.net/>`__ compression. This option uses less bandwidth compared to :ref:`COMPRESS_FASTLZ<class_ENetConnection_constant_COMPRESS_FASTLZ>`, at the expense of using more CPU resources.
  85. .. _class_ENetConnection_constant_COMPRESS_ZSTD:
  86. .. rst-class:: classref-enumeration-constant
  87. :ref:`CompressionMode<enum_ENetConnection_CompressionMode>` **COMPRESS_ZSTD** = ``4``
  88. `Zstandard <https://facebook.github.io/zstd/>`__ compression. Note that this algorithm is not very efficient on packets smaller than 4 KB. Therefore, it's recommended to use other compression algorithms in most cases.
  89. .. rst-class:: classref-item-separator
  90. ----
  91. .. _enum_ENetConnection_EventType:
  92. .. rst-class:: classref-enumeration
  93. enum **EventType**: :ref:`🔗<enum_ENetConnection_EventType>`
  94. .. _class_ENetConnection_constant_EVENT_ERROR:
  95. .. rst-class:: classref-enumeration-constant
  96. :ref:`EventType<enum_ENetConnection_EventType>` **EVENT_ERROR** = ``-1``
  97. An error occurred during :ref:`service<class_ENetConnection_method_service>`. You will likely need to :ref:`destroy<class_ENetConnection_method_destroy>` the host and recreate it.
  98. .. _class_ENetConnection_constant_EVENT_NONE:
  99. .. rst-class:: classref-enumeration-constant
  100. :ref:`EventType<enum_ENetConnection_EventType>` **EVENT_NONE** = ``0``
  101. No event occurred within the specified time limit.
  102. .. _class_ENetConnection_constant_EVENT_CONNECT:
  103. .. rst-class:: classref-enumeration-constant
  104. :ref:`EventType<enum_ENetConnection_EventType>` **EVENT_CONNECT** = ``1``
  105. A connection request initiated by enet_host_connect has completed. The array will contain the peer which successfully connected.
  106. .. _class_ENetConnection_constant_EVENT_DISCONNECT:
  107. .. rst-class:: classref-enumeration-constant
  108. :ref:`EventType<enum_ENetConnection_EventType>` **EVENT_DISCONNECT** = ``2``
  109. A peer has disconnected. This event is generated on a successful completion of a disconnect initiated by :ref:`ENetPacketPeer.peer_disconnect<class_ENetPacketPeer_method_peer_disconnect>`, if a peer has timed out, or if a connection request initialized by :ref:`connect_to_host<class_ENetConnection_method_connect_to_host>` has timed out. The array will contain the peer which disconnected. The data field contains user supplied data describing the disconnection, or 0, if none is available.
  110. .. _class_ENetConnection_constant_EVENT_RECEIVE:
  111. .. rst-class:: classref-enumeration-constant
  112. :ref:`EventType<enum_ENetConnection_EventType>` **EVENT_RECEIVE** = ``3``
  113. A packet has been received from a peer. The array will contain the peer which sent the packet and the channel number upon which the packet was received. The received packet will be queued to the associated :ref:`ENetPacketPeer<class_ENetPacketPeer>`.
  114. .. rst-class:: classref-item-separator
  115. ----
  116. .. _enum_ENetConnection_HostStatistic:
  117. .. rst-class:: classref-enumeration
  118. enum **HostStatistic**: :ref:`🔗<enum_ENetConnection_HostStatistic>`
  119. .. _class_ENetConnection_constant_HOST_TOTAL_SENT_DATA:
  120. .. rst-class:: classref-enumeration-constant
  121. :ref:`HostStatistic<enum_ENetConnection_HostStatistic>` **HOST_TOTAL_SENT_DATA** = ``0``
  122. Total data sent.
  123. .. _class_ENetConnection_constant_HOST_TOTAL_SENT_PACKETS:
  124. .. rst-class:: classref-enumeration-constant
  125. :ref:`HostStatistic<enum_ENetConnection_HostStatistic>` **HOST_TOTAL_SENT_PACKETS** = ``1``
  126. Total UDP packets sent.
  127. .. _class_ENetConnection_constant_HOST_TOTAL_RECEIVED_DATA:
  128. .. rst-class:: classref-enumeration-constant
  129. :ref:`HostStatistic<enum_ENetConnection_HostStatistic>` **HOST_TOTAL_RECEIVED_DATA** = ``2``
  130. Total data received.
  131. .. _class_ENetConnection_constant_HOST_TOTAL_RECEIVED_PACKETS:
  132. .. rst-class:: classref-enumeration-constant
  133. :ref:`HostStatistic<enum_ENetConnection_HostStatistic>` **HOST_TOTAL_RECEIVED_PACKETS** = ``3``
  134. Total UDP packets received.
  135. .. rst-class:: classref-section-separator
  136. ----
  137. .. rst-class:: classref-descriptions-group
  138. Method Descriptions
  139. -------------------
  140. .. _class_ENetConnection_method_bandwidth_limit:
  141. .. rst-class:: classref-method
  142. |void| **bandwidth_limit**\ (\ in_bandwidth\: :ref:`int<class_int>` = 0, out_bandwidth\: :ref:`int<class_int>` = 0\ ) :ref:`🔗<class_ENetConnection_method_bandwidth_limit>`
  143. Adjusts the bandwidth limits of a host.
  144. .. rst-class:: classref-item-separator
  145. ----
  146. .. _class_ENetConnection_method_broadcast:
  147. .. rst-class:: classref-method
  148. |void| **broadcast**\ (\ channel\: :ref:`int<class_int>`, packet\: :ref:`PackedByteArray<class_PackedByteArray>`, flags\: :ref:`int<class_int>`\ ) :ref:`🔗<class_ENetConnection_method_broadcast>`
  149. Queues a ``packet`` to be sent to all peers associated with the host over the specified ``channel``. See :ref:`ENetPacketPeer<class_ENetPacketPeer>` ``FLAG_*`` constants for available packet flags.
  150. .. rst-class:: classref-item-separator
  151. ----
  152. .. _class_ENetConnection_method_channel_limit:
  153. .. rst-class:: classref-method
  154. |void| **channel_limit**\ (\ limit\: :ref:`int<class_int>`\ ) :ref:`🔗<class_ENetConnection_method_channel_limit>`
  155. Limits the maximum allowed channels of future incoming connections.
  156. .. rst-class:: classref-item-separator
  157. ----
  158. .. _class_ENetConnection_method_compress:
  159. .. rst-class:: classref-method
  160. |void| **compress**\ (\ mode\: :ref:`CompressionMode<enum_ENetConnection_CompressionMode>`\ ) :ref:`🔗<class_ENetConnection_method_compress>`
  161. Sets the compression method used for network packets. These have different tradeoffs of compression speed versus bandwidth, you may need to test which one works best for your use case if you use compression at all.
  162. \ **Note:** Most games' network design involve sending many small packets frequently (smaller than 4 KB each). If in doubt, it is recommended to keep the default compression algorithm as it works best on these small packets.
  163. \ **Note:** The compression mode must be set to the same value on both the server and all its clients. Clients will fail to connect if the compression mode set on the client differs from the one set on the server.
  164. .. rst-class:: classref-item-separator
  165. ----
  166. .. _class_ENetConnection_method_connect_to_host:
  167. .. rst-class:: classref-method
  168. :ref:`ENetPacketPeer<class_ENetPacketPeer>` **connect_to_host**\ (\ address\: :ref:`String<class_String>`, port\: :ref:`int<class_int>`, channels\: :ref:`int<class_int>` = 0, data\: :ref:`int<class_int>` = 0\ ) :ref:`🔗<class_ENetConnection_method_connect_to_host>`
  169. Initiates a connection to a foreign ``address`` using the specified ``port`` and allocating the requested ``channels``. Optional ``data`` can be passed during connection in the form of a 32 bit integer.
  170. \ **Note:** You must call either :ref:`create_host<class_ENetConnection_method_create_host>` or :ref:`create_host_bound<class_ENetConnection_method_create_host_bound>` on both ends before calling this method.
  171. .. rst-class:: classref-item-separator
  172. ----
  173. .. _class_ENetConnection_method_create_host:
  174. .. rst-class:: classref-method
  175. :ref:`Error<enum_@GlobalScope_Error>` **create_host**\ (\ max_peers\: :ref:`int<class_int>` = 32, max_channels\: :ref:`int<class_int>` = 0, in_bandwidth\: :ref:`int<class_int>` = 0, out_bandwidth\: :ref:`int<class_int>` = 0\ ) :ref:`🔗<class_ENetConnection_method_create_host>`
  176. Creates an ENetHost that allows up to ``max_peers`` connected peers, each allocating up to ``max_channels`` channels, optionally limiting bandwidth to ``in_bandwidth`` and ``out_bandwidth`` (if greater than zero).
  177. This method binds a random available dynamic UDP port on the host machine at the *unspecified* address. Use :ref:`create_host_bound<class_ENetConnection_method_create_host_bound>` to specify the address and port.
  178. \ **Note:** It is necessary to create a host in both client and server in order to establish a connection.
  179. .. rst-class:: classref-item-separator
  180. ----
  181. .. _class_ENetConnection_method_create_host_bound:
  182. .. rst-class:: classref-method
  183. :ref:`Error<enum_@GlobalScope_Error>` **create_host_bound**\ (\ bind_address\: :ref:`String<class_String>`, bind_port\: :ref:`int<class_int>`, max_peers\: :ref:`int<class_int>` = 32, max_channels\: :ref:`int<class_int>` = 0, in_bandwidth\: :ref:`int<class_int>` = 0, out_bandwidth\: :ref:`int<class_int>` = 0\ ) :ref:`🔗<class_ENetConnection_method_create_host_bound>`
  184. Creates an ENetHost bound to the given ``bind_address`` and ``bind_port`` that allows up to ``max_peers`` connected peers, each allocating up to ``max_channels`` channels, optionally limiting bandwidth to ``in_bandwidth`` and ``out_bandwidth`` (if greater than zero).
  185. \ **Note:** It is necessary to create a host in both client and server in order to establish a connection.
  186. .. rst-class:: classref-item-separator
  187. ----
  188. .. _class_ENetConnection_method_destroy:
  189. .. rst-class:: classref-method
  190. |void| **destroy**\ (\ ) :ref:`🔗<class_ENetConnection_method_destroy>`
  191. Destroys the host and all resources associated with it.
  192. .. rst-class:: classref-item-separator
  193. ----
  194. .. _class_ENetConnection_method_dtls_client_setup:
  195. .. rst-class:: classref-method
  196. :ref:`Error<enum_@GlobalScope_Error>` **dtls_client_setup**\ (\ hostname\: :ref:`String<class_String>`, client_options\: :ref:`TLSOptions<class_TLSOptions>` = null\ ) :ref:`🔗<class_ENetConnection_method_dtls_client_setup>`
  197. Configure this ENetHost to use the custom Godot extension allowing DTLS encryption for ENet clients. Call this before :ref:`connect_to_host<class_ENetConnection_method_connect_to_host>` to have ENet connect using DTLS validating the server certificate against ``hostname``. You can pass the optional ``client_options`` parameter to customize the trusted certification authorities, or disable the common name verification. See :ref:`TLSOptions.client<class_TLSOptions_method_client>` and :ref:`TLSOptions.client_unsafe<class_TLSOptions_method_client_unsafe>`.
  198. .. rst-class:: classref-item-separator
  199. ----
  200. .. _class_ENetConnection_method_dtls_server_setup:
  201. .. rst-class:: classref-method
  202. :ref:`Error<enum_@GlobalScope_Error>` **dtls_server_setup**\ (\ server_options\: :ref:`TLSOptions<class_TLSOptions>`\ ) :ref:`🔗<class_ENetConnection_method_dtls_server_setup>`
  203. Configure this ENetHost to use the custom Godot extension allowing DTLS encryption for ENet servers. Call this right after :ref:`create_host_bound<class_ENetConnection_method_create_host_bound>` to have ENet expect peers to connect using DTLS. See :ref:`TLSOptions.server<class_TLSOptions_method_server>`.
  204. .. rst-class:: classref-item-separator
  205. ----
  206. .. _class_ENetConnection_method_flush:
  207. .. rst-class:: classref-method
  208. |void| **flush**\ (\ ) :ref:`🔗<class_ENetConnection_method_flush>`
  209. Sends any queued packets on the host specified to its designated peers.
  210. .. rst-class:: classref-item-separator
  211. ----
  212. .. _class_ENetConnection_method_get_local_port:
  213. .. rst-class:: classref-method
  214. :ref:`int<class_int>` **get_local_port**\ (\ ) |const| :ref:`🔗<class_ENetConnection_method_get_local_port>`
  215. Returns the local port to which this peer is bound.
  216. .. rst-class:: classref-item-separator
  217. ----
  218. .. _class_ENetConnection_method_get_max_channels:
  219. .. rst-class:: classref-method
  220. :ref:`int<class_int>` **get_max_channels**\ (\ ) |const| :ref:`🔗<class_ENetConnection_method_get_max_channels>`
  221. Returns the maximum number of channels allowed for connected peers.
  222. .. rst-class:: classref-item-separator
  223. ----
  224. .. _class_ENetConnection_method_get_peers:
  225. .. rst-class:: classref-method
  226. :ref:`Array<class_Array>`\[:ref:`ENetPacketPeer<class_ENetPacketPeer>`\] **get_peers**\ (\ ) :ref:`🔗<class_ENetConnection_method_get_peers>`
  227. Returns the list of peers associated with this host.
  228. \ **Note:** This list might include some peers that are not fully connected or are still being disconnected.
  229. .. rst-class:: classref-item-separator
  230. ----
  231. .. _class_ENetConnection_method_pop_statistic:
  232. .. rst-class:: classref-method
  233. :ref:`float<class_float>` **pop_statistic**\ (\ statistic\: :ref:`HostStatistic<enum_ENetConnection_HostStatistic>`\ ) :ref:`🔗<class_ENetConnection_method_pop_statistic>`
  234. Returns and resets host statistics. See :ref:`HostStatistic<enum_ENetConnection_HostStatistic>` for more info.
  235. .. rst-class:: classref-item-separator
  236. ----
  237. .. _class_ENetConnection_method_refuse_new_connections:
  238. .. rst-class:: classref-method
  239. |void| **refuse_new_connections**\ (\ refuse\: :ref:`bool<class_bool>`\ ) :ref:`🔗<class_ENetConnection_method_refuse_new_connections>`
  240. Configures the DTLS server to automatically drop new connections.
  241. \ **Note:** This method is only relevant after calling :ref:`dtls_server_setup<class_ENetConnection_method_dtls_server_setup>`.
  242. .. rst-class:: classref-item-separator
  243. ----
  244. .. _class_ENetConnection_method_service:
  245. .. rst-class:: classref-method
  246. :ref:`Array<class_Array>` **service**\ (\ timeout\: :ref:`int<class_int>` = 0\ ) :ref:`🔗<class_ENetConnection_method_service>`
  247. Waits for events on this connection and shuttles packets between the host and its peers, with the given ``timeout`` (in milliseconds). The returned :ref:`Array<class_Array>` will have 4 elements. An :ref:`EventType<enum_ENetConnection_EventType>`, the :ref:`ENetPacketPeer<class_ENetPacketPeer>` which generated the event, the event associated data (if any), the event associated channel (if any). If the generated event is :ref:`EVENT_RECEIVE<class_ENetConnection_constant_EVENT_RECEIVE>`, the received packet will be queued to the associated :ref:`ENetPacketPeer<class_ENetPacketPeer>`.
  248. Call this function regularly to handle connections, disconnections, and to receive new packets.
  249. \ **Note:** This method must be called on both ends involved in the event (sending and receiving hosts).
  250. .. rst-class:: classref-item-separator
  251. ----
  252. .. _class_ENetConnection_method_socket_send:
  253. .. rst-class:: classref-method
  254. |void| **socket_send**\ (\ destination_address\: :ref:`String<class_String>`, destination_port\: :ref:`int<class_int>`, packet\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) :ref:`🔗<class_ENetConnection_method_socket_send>`
  255. Sends a ``packet`` toward a destination from the address and port currently bound by this ENetConnection instance.
  256. This is useful as it serves to establish entries in NAT routing tables on all devices between this bound instance and the public facing internet, allowing a prospective client's connection packets to be routed backward through the NAT device(s) between the public internet and this host.
  257. This requires forward knowledge of a prospective client's address and communication port as seen by the public internet - after any NAT devices have handled their connection request. This information can be obtained by a `STUN <https://en.wikipedia.org/wiki/STUN>`__ service, and must be handed off to your host by an entity that is not the prospective client. This will never work for a client behind a Symmetric NAT due to the nature of the Symmetric NAT routing algorithm, as their IP and Port cannot be known beforehand.
  258. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  259. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  260. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  261. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  262. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  263. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  264. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  265. .. |void| replace:: :abbr:`void (No return value.)`