Files
godot-docs-l10n/classes/es/class_enetconnection.rst

473 lines
33 KiB
ReStructuredText

:github_url: hide
.. _class_ENetConnection:
ENetConnection
==============
**Hereda:** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
Una clase contenedora para un `ENetHost <http://enet.bespin.org/group__host.html>`__.
.. rst-class:: classref-introduction-group
Descripción
----------------------
ENet's purpose is to provide a relatively thin, simple and robust network communication layer on top of UDP (User Datagram Protocol).
.. rst-class:: classref-introduction-group
Tutoriales
--------------------
- `API documentation on the ENet website <http://enet.bespin.org/usergroup0.html>`__
.. rst-class:: classref-reftable-group
Métodos
--------------
.. table::
:widths: auto
+--------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`bandwidth_limit<class_ENetConnection_method_bandwidth_limit>`\ (\ in_bandwidth\: :ref:`int<class_int>` = 0, out_bandwidth\: :ref:`int<class_int>` = 0\ ) |
+--------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`broadcast<class_ENetConnection_method_broadcast>`\ (\ channel\: :ref:`int<class_int>`, packet\: :ref:`PackedByteArray<class_PackedByteArray>`, flags\: :ref:`int<class_int>`\ ) |
+--------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`channel_limit<class_ENetConnection_method_channel_limit>`\ (\ limit\: :ref:`int<class_int>`\ ) |
+--------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`compress<class_ENetConnection_method_compress>`\ (\ mode\: :ref:`CompressionMode<enum_ENetConnection_CompressionMode>`\ ) |
+--------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :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\ ) |
+--------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :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\ ) |
+--------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :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\ ) |
+--------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`destroy<class_ENetConnection_method_destroy>`\ (\ ) |
+--------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :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\ ) |
+--------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Error<enum_@GlobalScope_Error>` | :ref:`dtls_server_setup<class_ENetConnection_method_dtls_server_setup>`\ (\ server_options\: :ref:`TLSOptions<class_TLSOptions>`\ ) |
+--------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`flush<class_ENetConnection_method_flush>`\ (\ ) |
+--------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`int<class_int>` | :ref:`get_local_port<class_ENetConnection_method_get_local_port>`\ (\ ) |const| |
+--------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`int<class_int>` | :ref:`get_max_channels<class_ENetConnection_method_get_max_channels>`\ (\ ) |const| |
+--------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Array<class_Array>`\[:ref:`ENetPacketPeer<class_ENetPacketPeer>`\] | :ref:`get_peers<class_ENetConnection_method_get_peers>`\ (\ ) |
+--------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`float<class_float>` | :ref:`pop_statistic<class_ENetConnection_method_pop_statistic>`\ (\ statistic\: :ref:`HostStatistic<enum_ENetConnection_HostStatistic>`\ ) |
+--------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`refuse_new_connections<class_ENetConnection_method_refuse_new_connections>`\ (\ refuse\: :ref:`bool<class_bool>`\ ) |
+--------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Array<class_Array>` | :ref:`service<class_ENetConnection_method_service>`\ (\ timeout\: :ref:`int<class_int>` = 0\ ) |
+--------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |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>`\ ) |
+--------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
Enumeraciones
--------------------------
.. _enum_ENetConnection_CompressionMode:
.. rst-class:: classref-enumeration
enum **CompressionMode**: :ref:`🔗<enum_ENetConnection_CompressionMode>`
.. _class_ENetConnection_constant_COMPRESS_NONE:
.. rst-class:: classref-enumeration-constant
:ref:`CompressionMode<enum_ENetConnection_CompressionMode>` **COMPRESS_NONE** = ``0``
Sin compresión. Utiliza el mayor ancho de banda, pero tiene la ventaja de requerir la menor cantidad de recursos de la CPU. Esta opción también se puede utilizar para facilitar la depuración de la red mediante herramientas como Wireshark.
.. _class_ENetConnection_constant_COMPRESS_RANGE_CODER:
.. rst-class:: classref-enumeration-constant
:ref:`CompressionMode<enum_ENetConnection_CompressionMode>` **COMPRESS_RANGE_CODER** = ``1``
Codificación de rango incorporada de ENet. Funciona bien en paquetes pequeños, pero no es el algoritmo más eficiente en paquetes de más de 4 KB.
.. _class_ENetConnection_constant_COMPRESS_FASTLZ:
.. rst-class:: classref-enumeration-constant
:ref:`CompressionMode<enum_ENetConnection_CompressionMode>` **COMPRESS_FASTLZ** = ``2``
Compresión `FastLZ <https://fastlz.org/>`__. Esta opción utiliza menos recursos de CPU en comparación con :ref:`COMPRESS_ZLIB<class_ENetConnection_constant_COMPRESS_ZLIB>`, a expensas de utilizar más ancho de banda.
.. _class_ENetConnection_constant_COMPRESS_ZLIB:
.. rst-class:: classref-enumeration-constant
:ref:`CompressionMode<enum_ENetConnection_CompressionMode>` **COMPRESS_ZLIB** = ``3``
Compresión `Zlib <https://www.zlib.net/>`__. Esta opción utiliza menos ancho de banda en comparación con :ref:`COMPRESS_FASTLZ<class_ENetConnection_constant_COMPRESS_FASTLZ>`, a expensas de utilizar más recursos de la CPU.
.. _class_ENetConnection_constant_COMPRESS_ZSTD:
.. rst-class:: classref-enumeration-constant
:ref:`CompressionMode<enum_ENetConnection_CompressionMode>` **COMPRESS_ZSTD** = ``4``
Compresión `Zstandard <https://facebook.github.io/zstd/>`__. Ten en cuenta que este algoritmo no es muy eficiente en paquetes más pequeños de 4 KB. Por lo tanto, se recomienda utilizar otros algoritmos de compresión en la mayoría de los casos.
.. rst-class:: classref-item-separator
----
.. _enum_ENetConnection_EventType:
.. rst-class:: classref-enumeration
enum **EventType**: :ref:`🔗<enum_ENetConnection_EventType>`
.. _class_ENetConnection_constant_EVENT_ERROR:
.. rst-class:: classref-enumeration-constant
:ref:`EventType<enum_ENetConnection_EventType>` **EVENT_ERROR** = ``-1``
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.
.. _class_ENetConnection_constant_EVENT_NONE:
.. rst-class:: classref-enumeration-constant
:ref:`EventType<enum_ENetConnection_EventType>` **EVENT_NONE** = ``0``
No event occurred within the specified time limit.
.. _class_ENetConnection_constant_EVENT_CONNECT:
.. rst-class:: classref-enumeration-constant
:ref:`EventType<enum_ENetConnection_EventType>` **EVENT_CONNECT** = ``1``
A connection request initiated by enet_host_connect has completed. The array will contain the peer which successfully connected.
.. _class_ENetConnection_constant_EVENT_DISCONNECT:
.. rst-class:: classref-enumeration-constant
:ref:`EventType<enum_ENetConnection_EventType>` **EVENT_DISCONNECT** = ``2``
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.
.. _class_ENetConnection_constant_EVENT_RECEIVE:
.. rst-class:: classref-enumeration-constant
:ref:`EventType<enum_ENetConnection_EventType>` **EVENT_RECEIVE** = ``3``
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>`.
.. rst-class:: classref-item-separator
----
.. _enum_ENetConnection_HostStatistic:
.. rst-class:: classref-enumeration
enum **HostStatistic**: :ref:`🔗<enum_ENetConnection_HostStatistic>`
.. _class_ENetConnection_constant_HOST_TOTAL_SENT_DATA:
.. rst-class:: classref-enumeration-constant
:ref:`HostStatistic<enum_ENetConnection_HostStatistic>` **HOST_TOTAL_SENT_DATA** = ``0``
Datos totales enviados.
.. _class_ENetConnection_constant_HOST_TOTAL_SENT_PACKETS:
.. rst-class:: classref-enumeration-constant
:ref:`HostStatistic<enum_ENetConnection_HostStatistic>` **HOST_TOTAL_SENT_PACKETS** = ``1``
Total de paquetes UDP enviados.
.. _class_ENetConnection_constant_HOST_TOTAL_RECEIVED_DATA:
.. rst-class:: classref-enumeration-constant
:ref:`HostStatistic<enum_ENetConnection_HostStatistic>` **HOST_TOTAL_RECEIVED_DATA** = ``2``
Datos totales recibidos.
.. _class_ENetConnection_constant_HOST_TOTAL_RECEIVED_PACKETS:
.. rst-class:: classref-enumeration-constant
:ref:`HostStatistic<enum_ENetConnection_HostStatistic>` **HOST_TOTAL_RECEIVED_PACKETS** = ``3``
Total de paquetes UDP recibidos.
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
Descripciones de Métodos
------------------------------------------------
.. _class_ENetConnection_method_bandwidth_limit:
.. rst-class:: classref-method
|void| **bandwidth_limit**\ (\ in_bandwidth\: :ref:`int<class_int>` = 0, out_bandwidth\: :ref:`int<class_int>` = 0\ ) :ref:`🔗<class_ENetConnection_method_bandwidth_limit>`
Adjusts the bandwidth limits of a host.
.. rst-class:: classref-item-separator
----
.. _class_ENetConnection_method_broadcast:
.. rst-class:: classref-method
|void| **broadcast**\ (\ channel\: :ref:`int<class_int>`, packet\: :ref:`PackedByteArray<class_PackedByteArray>`, flags\: :ref:`int<class_int>`\ ) :ref:`🔗<class_ENetConnection_method_broadcast>`
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.
.. rst-class:: classref-item-separator
----
.. _class_ENetConnection_method_channel_limit:
.. rst-class:: classref-method
|void| **channel_limit**\ (\ limit\: :ref:`int<class_int>`\ ) :ref:`🔗<class_ENetConnection_method_channel_limit>`
Limits the maximum allowed channels of future incoming connections.
.. rst-class:: classref-item-separator
----
.. _class_ENetConnection_method_compress:
.. rst-class:: classref-method
|void| **compress**\ (\ mode\: :ref:`CompressionMode<enum_ENetConnection_CompressionMode>`\ ) :ref:`🔗<class_ENetConnection_method_compress>`
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.
\ **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.
\ **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.
.. rst-class:: classref-item-separator
----
.. _class_ENetConnection_method_connect_to_host:
.. rst-class:: classref-method
: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>`
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.
\ **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.
.. rst-class:: classref-item-separator
----
.. _class_ENetConnection_method_create_host:
.. rst-class:: classref-method
: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>`
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).
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.
\ **Note:** It is necessary to create a host in both client and server in order to establish a connection.
.. rst-class:: classref-item-separator
----
.. _class_ENetConnection_method_create_host_bound:
.. rst-class:: classref-method
: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>`
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).
\ **Note:** It is necessary to create a host in both client and server in order to establish a connection.
.. rst-class:: classref-item-separator
----
.. _class_ENetConnection_method_destroy:
.. rst-class:: classref-method
|void| **destroy**\ (\ ) :ref:`🔗<class_ENetConnection_method_destroy>`
Destruye el host y todos los recursos asociados a él.
.. rst-class:: classref-item-separator
----
.. _class_ENetConnection_method_dtls_client_setup:
.. rst-class:: classref-method
: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>`
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>`.
.. rst-class:: classref-item-separator
----
.. _class_ENetConnection_method_dtls_server_setup:
.. rst-class:: classref-method
:ref:`Error<enum_@GlobalScope_Error>` **dtls_server_setup**\ (\ server_options\: :ref:`TLSOptions<class_TLSOptions>`\ ) :ref:`🔗<class_ENetConnection_method_dtls_server_setup>`
Configura este ENetHost para usar la extensión personalizada de Godot que permite el cifrado DTLS para servidores ENet. Llama a esto justo después de :ref:`create_host_bound()<class_ENetConnection_method_create_host_bound>` para que ENet espere que los pares se conecten usando DTLS. Véase :ref:`TLSOptions.server()<class_TLSOptions_method_server>`.
.. rst-class:: classref-item-separator
----
.. _class_ENetConnection_method_flush:
.. rst-class:: classref-method
|void| **flush**\ (\ ) :ref:`🔗<class_ENetConnection_method_flush>`
Sends any queued packets on the host specified to its designated peers.
.. rst-class:: classref-item-separator
----
.. _class_ENetConnection_method_get_local_port:
.. rst-class:: classref-method
:ref:`int<class_int>` **get_local_port**\ (\ ) |const| :ref:`🔗<class_ENetConnection_method_get_local_port>`
Returns the local port to which this peer is bound.
.. rst-class:: classref-item-separator
----
.. _class_ENetConnection_method_get_max_channels:
.. rst-class:: classref-method
:ref:`int<class_int>` **get_max_channels**\ (\ ) |const| :ref:`🔗<class_ENetConnection_method_get_max_channels>`
Returns the maximum number of channels allowed for connected peers.
.. rst-class:: classref-item-separator
----
.. _class_ENetConnection_method_get_peers:
.. rst-class:: classref-method
:ref:`Array<class_Array>`\[:ref:`ENetPacketPeer<class_ENetPacketPeer>`\] **get_peers**\ (\ ) :ref:`🔗<class_ENetConnection_method_get_peers>`
Returns the list of peers associated with this host.
\ **Note:** This list might include some peers that are not fully connected or are still being disconnected.
.. rst-class:: classref-item-separator
----
.. _class_ENetConnection_method_pop_statistic:
.. rst-class:: classref-method
:ref:`float<class_float>` **pop_statistic**\ (\ statistic\: :ref:`HostStatistic<enum_ENetConnection_HostStatistic>`\ ) :ref:`🔗<class_ENetConnection_method_pop_statistic>`
Devuelve y restablece las estadísticas del host.
.. rst-class:: classref-item-separator
----
.. _class_ENetConnection_method_refuse_new_connections:
.. rst-class:: classref-method
|void| **refuse_new_connections**\ (\ refuse\: :ref:`bool<class_bool>`\ ) :ref:`🔗<class_ENetConnection_method_refuse_new_connections>`
Configura el servidor DTLS para que descarte automáticamente las nuevas conexiones.
\ **Nota:** Este método solo es relevante después de llamar a :ref:`dtls_server_setup()<class_ENetConnection_method_dtls_server_setup>`.
.. rst-class:: classref-item-separator
----
.. _class_ENetConnection_method_service:
.. rst-class:: classref-method
:ref:`Array<class_Array>` **service**\ (\ timeout\: :ref:`int<class_int>` = 0\ ) :ref:`🔗<class_ENetConnection_method_service>`
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>`.
Call this function regularly to handle connections, disconnections, and to receive new packets.
\ **Note:** This method must be called on both ends involved in the event (sending and receiving hosts).
.. rst-class:: classref-item-separator
----
.. _class_ENetConnection_method_socket_send:
.. rst-class:: classref-method
|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>`
Sends a ``packet`` toward a destination from the address and port currently bound by this ENetConnection instance.
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.
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.
.. |virtual| replace:: :abbr:`virtual (Normalmente, este método debería ser sobreescrito por el usuario para que tenga algún efecto.)`
.. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)`
.. |const| replace:: :abbr:`const (Este método no tiene efectos secundarios. No modifica ninguna de las variables miembro de la instancia.)`
.. |vararg| replace:: :abbr:`vararg (Este método permite agregar cualquier número de argumentos después de los descritos aquí.)`
.. |constructor| replace:: :abbr:`constructor (Este método se utiliza para construir un tipo.)`
.. |static| replace:: :abbr:`static (Este método no necesita una instancia para ser llamado, por lo que puede llamarse directamente utilizando el nombre de la clase.)`
.. |operator| replace:: :abbr:`operator (Este método describe un operador válido para usar con este tipo como operando izquierdo.)`
.. |bitfield| replace:: :abbr:`BitField (Este valor es un entero compuesto como una máscara de bits de las siguientes banderas.)`
.. |void| replace:: :abbr:`void (Sin valor de retorno.)`