Files
godot-docs-l10n/classes/fr/class_upnp.rst
2025-12-19 14:34:07 +01:00

594 lines
30 KiB
ReStructuredText
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

:github_url: hide
.. _class_UPNP:
UPNP
====
**Hérite de:** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
Fonctions Universal Plug and Play (UPnP, litt. "Brancher et jouer Universel") pour la découverte de périphériques, les requêtes et la redirection de port sur un réseau.
.. rst-class:: classref-introduction-group
Description
-----------
This class can be used to discover compatible :ref:`UPNPDevice<class_UPNPDevice>`\ s on the local network and execute commands on them, like managing port mappings (for port forwarding/NAT traversal) and querying the local and remote network IP address. Note that methods on this class are synchronous and block the calling thread.
To forward a specific port (here ``7777``, note both :ref:`discover()<class_UPNP_method_discover>` and :ref:`add_port_mapping()<class_UPNP_method_add_port_mapping>` can return errors that should be checked):
::
var upnp = UPNP.new()
upnp.discover()
upnp.add_port_mapping(7777)
To close a specific port (e.g. after you have finished using it):
::
upnp.delete_port_mapping(port)
\ **Note:** UPnP discovery blocks the current thread. To perform discovery without blocking the main thread, use :ref:`Thread<class_Thread>`\ s like this:
::
# Emitted when UPnP port mapping setup is completed (regardless of success or failure).
signal upnp_completed(error)
# Replace this with your own server port number between 1024 and 65535.
const SERVER_PORT = 3928
var thread = null
func _upnp_setup(server_port):
# UPNP queries take some time.
var upnp = UPNP.new()
var err = upnp.discover()
if err != OK:
push_error(str(err))
upnp_completed.emit(err)
return
if upnp.get_gateway() and upnp.get_gateway().is_valid_gateway():
upnp.add_port_mapping(server_port, server_port, ProjectSettings.get_setting("application/config/name"), "UDP")
upnp.add_port_mapping(server_port, server_port, ProjectSettings.get_setting("application/config/name"), "TCP")
upnp_completed.emit(OK)
func _ready():
thread = Thread.new()
thread.start(_upnp_setup.bind(SERVER_PORT))
func _exit_tree():
# Wait for thread finish here to handle game exit while the thread is running.
thread.wait_to_finish()
\ **Terminology:** In the context of UPnP networking, "gateway" (or "internet gateway device", short IGD) refers to network devices that allow computers in the local network to access the internet ("wide area network", WAN). These gateways are often also called "routers".
\ **Pitfalls:**\
- As explained above, these calls are blocking and shouldn't be run on the main thread, especially as they can block for multiple seconds at a time. Use threading!
- Networking is physical and messy. Packets get lost in transit or get filtered, addresses, free ports and assigned mappings change, and devices may leave or join the network at any time. Be mindful of this, be diligent when checking and handling errors, and handle these gracefully if you can: add clear error UI, timeouts and re-try handling.
- Port mappings may change (and be removed) at any time, and the remote/external IP address of the gateway can change likewise. You should consider re-querying the external IP and try to update/refresh the port mapping periodically (for example, every 5 minutes and on networking failures).
- Not all devices support UPnP, and some users disable UPnP support. You need to handle this (e.g. documenting and requiring the user to manually forward ports, or adding alternative methods of NAT traversal, like a relay/mirror server, or NAT hole punching, STUN/TURN, etc.).
- Consider what happens on mapping conflicts. Maybe multiple users on the same network would like to play your game at the same time, or maybe another application uses the same port. Make the port configurable, and optimally choose a port automatically (re-trying with a different port on failure).
\ **Further reading:** If you want to know more about UPnP (and the Internet Gateway Device (IGD) and Port Control Protocol (PCP) specifically), `Wikipedia <https://en.wikipedia.org/wiki/Universal_Plug_and_Play>`__ is a good first stop, the specification can be found at the `Open Connectivity Foundation <https://openconnectivity.org/developer/specifications/upnp-resources/upnp/>`__ and Godot's implementation is based on the `MiniUPnP client <https://github.com/miniupnp/miniupnp>`__.
.. rst-class:: classref-reftable-group
Propriétés
--------------------
.. table::
:widths: auto
+-----------------------------+-------------------------------------------------------------------------+-----------+
| :ref:`bool<class_bool>` | :ref:`discover_ipv6<class_UPNP_property_discover_ipv6>` | ``false`` |
+-----------------------------+-------------------------------------------------------------------------+-----------+
| :ref:`int<class_int>` | :ref:`discover_local_port<class_UPNP_property_discover_local_port>` | ``0`` |
+-----------------------------+-------------------------------------------------------------------------+-----------+
| :ref:`String<class_String>` | :ref:`discover_multicast_if<class_UPNP_property_discover_multicast_if>` | ``""`` |
+-----------------------------+-------------------------------------------------------------------------+-----------+
.. rst-class:: classref-reftable-group
Méthodes
----------------
.. table::
:widths: auto
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`add_device<class_UPNP_method_add_device>`\ (\ device\: :ref:`UPNPDevice<class_UPNPDevice>`\ ) |
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`int<class_int>` | :ref:`add_port_mapping<class_UPNP_method_add_port_mapping>`\ (\ port\: :ref:`int<class_int>`, port_internal\: :ref:`int<class_int>` = 0, desc\: :ref:`String<class_String>` = "", proto\: :ref:`String<class_String>` = "UDP", duration\: :ref:`int<class_int>` = 0\ ) |const| |
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`clear_devices<class_UPNP_method_clear_devices>`\ (\ ) |
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`int<class_int>` | :ref:`delete_port_mapping<class_UPNP_method_delete_port_mapping>`\ (\ port\: :ref:`int<class_int>`, proto\: :ref:`String<class_String>` = "UDP"\ ) |const| |
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`int<class_int>` | :ref:`discover<class_UPNP_method_discover>`\ (\ timeout\: :ref:`int<class_int>` = 2000, ttl\: :ref:`int<class_int>` = 2, device_filter\: :ref:`String<class_String>` = "InternetGatewayDevice"\ ) |
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`UPNPDevice<class_UPNPDevice>` | :ref:`get_device<class_UPNP_method_get_device>`\ (\ index\: :ref:`int<class_int>`\ ) |const| |
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`int<class_int>` | :ref:`get_device_count<class_UPNP_method_get_device_count>`\ (\ ) |const| |
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`UPNPDevice<class_UPNPDevice>` | :ref:`get_gateway<class_UPNP_method_get_gateway>`\ (\ ) |const| |
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`String<class_String>` | :ref:`query_external_address<class_UPNP_method_query_external_address>`\ (\ ) |const| |
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`remove_device<class_UPNP_method_remove_device>`\ (\ index\: :ref:`int<class_int>`\ ) |
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| |void| | :ref:`set_device<class_UPNP_method_set_device>`\ (\ index\: :ref:`int<class_int>`, device\: :ref:`UPNPDevice<class_UPNPDevice>`\ ) |
+-------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
Énumérations
------------------------
.. _enum_UPNP_UPNPResult:
.. rst-class:: classref-enumeration
enum **UPNPResult**: :ref:`🔗<enum_UPNP_UPNPResult>`
.. _class_UPNP_constant_UPNP_RESULT_SUCCESS:
.. rst-class:: classref-enumeration-constant
:ref:`UPNPResult<enum_UPNP_UPNPResult>` **UPNP_RESULT_SUCCESS** = ``0``
La commande ou la découverte UPNP a réussi.
.. _class_UPNP_constant_UPNP_RESULT_NOT_AUTHORIZED:
.. rst-class:: classref-enumeration-constant
:ref:`UPNPResult<enum_UPNP_UPNPResult>` **UPNP_RESULT_NOT_AUTHORIZED** = ``1``
Non autorisé à utiliser la commande sur le :ref:`UPNPDevice<class_UPNPDevice>`. Peut être retourné lorsque l'utilisateur a désactivé UPNP sur son routeur.
.. _class_UPNP_constant_UPNP_RESULT_PORT_MAPPING_NOT_FOUND:
.. rst-class:: classref-enumeration-constant
:ref:`UPNPResult<enum_UPNP_UPNPResult>` **UPNP_RESULT_PORT_MAPPING_NOT_FOUND** = ``2``
Aucune carte des ports n'a été trouvée pour le port donné, la combinaison de protocole sur le :ref:`UPNPDevice<class_UPNPDevice>` donné.
.. _class_UPNP_constant_UPNP_RESULT_INCONSISTENT_PARAMETERS:
.. rst-class:: classref-enumeration-constant
:ref:`UPNPResult<enum_UPNP_UPNPResult>` **UPNP_RESULT_INCONSISTENT_PARAMETERS** = ``3``
Paramètres inconsistants.
.. _class_UPNP_constant_UPNP_RESULT_NO_SUCH_ENTRY_IN_ARRAY:
.. rst-class:: classref-enumeration-constant
:ref:`UPNPResult<enum_UPNP_UPNPResult>` **UPNP_RESULT_NO_SUCH_ENTRY_IN_ARRAY** = ``4``
Aucune telle entrée dans le tableau. Peut être renvoyé si pour une combinaison de port/protocole donnée n'est pas trouvée sur un :ref:`UPNPDevice<class_UPNPDevice>`.
.. _class_UPNP_constant_UPNP_RESULT_ACTION_FAILED:
.. rst-class:: classref-enumeration-constant
:ref:`UPNPResult<enum_UPNP_UPNPResult>` **UPNP_RESULT_ACTION_FAILED** = ``5``
Laction a échoué.
.. _class_UPNP_constant_UPNP_RESULT_SRC_IP_WILDCARD_NOT_PERMITTED:
.. rst-class:: classref-enumeration-constant
:ref:`UPNPResult<enum_UPNP_UPNPResult>` **UPNP_RESULT_SRC_IP_WILDCARD_NOT_PERMITTED** = ``6``
Le :ref:`UPNPDevice<class_UPNPDevice>` ne permet pas les valeurs joker pour l'adresse IP source.
.. _class_UPNP_constant_UPNP_RESULT_EXT_PORT_WILDCARD_NOT_PERMITTED:
.. rst-class:: classref-enumeration-constant
:ref:`UPNPResult<enum_UPNP_UPNPResult>` **UPNP_RESULT_EXT_PORT_WILDCARD_NOT_PERMITTED** = ``7``
Les :ref:`UPNPDevice<class_UPNPDevice>` n'autorisent pas les astérismes pour les ports externes.
.. _class_UPNP_constant_UPNP_RESULT_INT_PORT_WILDCARD_NOT_PERMITTED:
.. rst-class:: classref-enumeration-constant
:ref:`UPNPResult<enum_UPNP_UPNPResult>` **UPNP_RESULT_INT_PORT_WILDCARD_NOT_PERMITTED** = ``8``
Les :ref:`UPNPDevice<class_UPNPDevice>` n'autorisent pas les astérismes pour les ports internes.
.. _class_UPNP_constant_UPNP_RESULT_REMOTE_HOST_MUST_BE_WILDCARD:
.. rst-class:: classref-enumeration-constant
:ref:`UPNPResult<enum_UPNP_UPNPResult>` **UPNP_RESULT_REMOTE_HOST_MUST_BE_WILDCARD** = ``9``
La valeur de l'hôte distante doit être un astérisme.
.. _class_UPNP_constant_UPNP_RESULT_EXT_PORT_MUST_BE_WILDCARD:
.. rst-class:: classref-enumeration-constant
:ref:`UPNPResult<enum_UPNP_UPNPResult>` **UPNP_RESULT_EXT_PORT_MUST_BE_WILDCARD** = ``10``
La valeur du port externe doit être un astérisme.
.. _class_UPNP_constant_UPNP_RESULT_NO_PORT_MAPS_AVAILABLE:
.. rst-class:: classref-enumeration-constant
:ref:`UPNPResult<enum_UPNP_UPNPResult>` **UPNP_RESULT_NO_PORT_MAPS_AVAILABLE** = ``11``
Aucune carte de ports n'est disponible. Peut également être retourné si la fonctionnalité de carte des ports n'est pas disponible.
.. _class_UPNP_constant_UPNP_RESULT_CONFLICT_WITH_OTHER_MECHANISM:
.. rst-class:: classref-enumeration-constant
:ref:`UPNPResult<enum_UPNP_UPNPResult>` **UPNP_RESULT_CONFLICT_WITH_OTHER_MECHANISM** = ``12``
Est en conflit avec un autre mécanisme. Peut être retourné au lieu de :ref:`UPNP_RESULT_CONFLICT_WITH_OTHER_MAPPING<class_UPNP_constant_UPNP_RESULT_CONFLICT_WITH_OTHER_MAPPING>` si une carte des ports est en conflit avec une carte existante.
.. _class_UPNP_constant_UPNP_RESULT_CONFLICT_WITH_OTHER_MAPPING:
.. rst-class:: classref-enumeration-constant
:ref:`UPNPResult<enum_UPNP_UPNPResult>` **UPNP_RESULT_CONFLICT_WITH_OTHER_MAPPING** = ``13``
Est en conflit avec une carte des ports existante.
.. _class_UPNP_constant_UPNP_RESULT_SAME_PORT_VALUES_REQUIRED:
.. rst-class:: classref-enumeration-constant
:ref:`UPNPResult<enum_UPNP_UPNPResult>` **UPNP_RESULT_SAME_PORT_VALUES_REQUIRED** = ``14``
Le port externe et interne doivent être les mêmes.
.. _class_UPNP_constant_UPNP_RESULT_ONLY_PERMANENT_LEASE_SUPPORTED:
.. rst-class:: classref-enumeration-constant
:ref:`UPNPResult<enum_UPNP_UPNPResult>` **UPNP_RESULT_ONLY_PERMANENT_LEASE_SUPPORTED** = ``15``
Seuls les baux permanents sont pris en charge. N'utilisez pas le paramètre ``duration`` lors de l'ajout de carte des ports.
.. _class_UPNP_constant_UPNP_RESULT_INVALID_GATEWAY:
.. rst-class:: classref-enumeration-constant
:ref:`UPNPResult<enum_UPNP_UPNPResult>` **UPNP_RESULT_INVALID_GATEWAY** = ``16``
Passerelle invalide.
.. _class_UPNP_constant_UPNP_RESULT_INVALID_PORT:
.. rst-class:: classref-enumeration-constant
:ref:`UPNPResult<enum_UPNP_UPNPResult>` **UPNP_RESULT_INVALID_PORT** = ``17``
Port invalide.
.. _class_UPNP_constant_UPNP_RESULT_INVALID_PROTOCOL:
.. rst-class:: classref-enumeration-constant
:ref:`UPNPResult<enum_UPNP_UPNPResult>` **UPNP_RESULT_INVALID_PROTOCOL** = ``18``
Protocole invalide.
.. _class_UPNP_constant_UPNP_RESULT_INVALID_DURATION:
.. rst-class:: classref-enumeration-constant
:ref:`UPNPResult<enum_UPNP_UPNPResult>` **UPNP_RESULT_INVALID_DURATION** = ``19``
Durée non valide.
.. _class_UPNP_constant_UPNP_RESULT_INVALID_ARGS:
.. rst-class:: classref-enumeration-constant
:ref:`UPNPResult<enum_UPNP_UPNPResult>` **UPNP_RESULT_INVALID_ARGS** = ``20``
Arguments non valides.
.. _class_UPNP_constant_UPNP_RESULT_INVALID_RESPONSE:
.. rst-class:: classref-enumeration-constant
:ref:`UPNPResult<enum_UPNP_UPNPResult>` **UPNP_RESULT_INVALID_RESPONSE** = ``21``
Réponse invalide.
.. _class_UPNP_constant_UPNP_RESULT_INVALID_PARAM:
.. rst-class:: classref-enumeration-constant
:ref:`UPNPResult<enum_UPNP_UPNPResult>` **UPNP_RESULT_INVALID_PARAM** = ``22``
Paramètre invalide.
.. _class_UPNP_constant_UPNP_RESULT_HTTP_ERROR:
.. rst-class:: classref-enumeration-constant
:ref:`UPNPResult<enum_UPNP_UPNPResult>` **UPNP_RESULT_HTTP_ERROR** = ``23``
Erreur HTTP.
.. _class_UPNP_constant_UPNP_RESULT_SOCKET_ERROR:
.. rst-class:: classref-enumeration-constant
:ref:`UPNPResult<enum_UPNP_UPNPResult>` **UPNP_RESULT_SOCKET_ERROR** = ``24``
Erreur de socket.
.. _class_UPNP_constant_UPNP_RESULT_MEM_ALLOC_ERROR:
.. rst-class:: classref-enumeration-constant
:ref:`UPNPResult<enum_UPNP_UPNPResult>` **UPNP_RESULT_MEM_ALLOC_ERROR** = ``25``
Erreur dallocation de mémoire.
.. _class_UPNP_constant_UPNP_RESULT_NO_GATEWAY:
.. rst-class:: classref-enumeration-constant
:ref:`UPNPResult<enum_UPNP_UPNPResult>` **UPNP_RESULT_NO_GATEWAY** = ``26``
Aucune passerelle disponible. Vous pouvez avoir besoin d'appeler :ref:`discover()<class_UPNP_method_discover>` d'abord, ou la découverte n'a pas détecté de IGD (InternetGatewayDevices) valide.
.. _class_UPNP_constant_UPNP_RESULT_NO_DEVICES:
.. rst-class:: classref-enumeration-constant
:ref:`UPNPResult<enum_UPNP_UPNPResult>` **UPNP_RESULT_NO_DEVICES** = ``27``
Aucun appareil disponible. Vous pouvez avoir besoin d'appeler :ref:`discover()<class_UPNP_method_discover>` d'abord, ou la découverte n'a pas détecté des :ref:`UPNPDevice<class_UPNPDevice>` valides.
.. _class_UPNP_constant_UPNP_RESULT_UNKNOWN_ERROR:
.. rst-class:: classref-enumeration-constant
:ref:`UPNPResult<enum_UPNP_UPNPResult>` **UPNP_RESULT_UNKNOWN_ERROR** = ``28``
Erreur inconnue.
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
Descriptions des propriétés
------------------------------------------------------
.. _class_UPNP_property_discover_ipv6:
.. rst-class:: classref-property
:ref:`bool<class_bool>` **discover_ipv6** = ``false`` :ref:`🔗<class_UPNP_property_discover_ipv6>`
.. rst-class:: classref-property-setget
- |void| **set_discover_ipv6**\ (\ value\: :ref:`bool<class_bool>`\ )
- :ref:`bool<class_bool>` **is_discover_ipv6**\ (\ )
Si ``true``, l'IPv6 est utilisée pour la découverte des :ref:`UPNPDevice<class_UPNPDevice>`.
.. rst-class:: classref-item-separator
----
.. _class_UPNP_property_discover_local_port:
.. rst-class:: classref-property
:ref:`int<class_int>` **discover_local_port** = ``0`` :ref:`🔗<class_UPNP_property_discover_local_port>`
.. rst-class:: classref-property-setget
- |void| **set_discover_local_port**\ (\ value\: :ref:`int<class_int>`\ )
- :ref:`int<class_int>` **get_discover_local_port**\ (\ )
Si ``0``, le port local à utiliser pour la découverte est choisi automatiquement par le système. Si ``1``, la découverte sera faite à partir du port source 1900 (même comme port de destination.) Sinon, la valeur sera utilisée comme port.
.. rst-class:: classref-item-separator
----
.. _class_UPNP_property_discover_multicast_if:
.. rst-class:: classref-property
:ref:`String<class_String>` **discover_multicast_if** = ``""`` :ref:`🔗<class_UPNP_property_discover_multicast_if>`
.. rst-class:: classref-property-setget
- |void| **set_discover_multicast_if**\ (\ value\: :ref:`String<class_String>`\ )
- :ref:`String<class_String>` **get_discover_multicast_if**\ (\ )
L'interface multicast à utiliser pour la découverte. Utilise l'interface multicast par défaut si vide.
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
Descriptions des méthodes
--------------------------------------------------
.. _class_UPNP_method_add_device:
.. rst-class:: classref-method
|void| **add_device**\ (\ device\: :ref:`UPNPDevice<class_UPNPDevice>`\ ) :ref:`🔗<class_UPNP_method_add_device>`
Ajouter le :ref:`UPNPDevice<class_UPNPDevice>` spécifié à la liste des appareils découverts.
.. rst-class:: classref-item-separator
----
.. _class_UPNP_method_add_port_mapping:
.. rst-class:: classref-method
:ref:`int<class_int>` **add_port_mapping**\ (\ port\: :ref:`int<class_int>`, port_internal\: :ref:`int<class_int>` = 0, desc\: :ref:`String<class_String>` = "", proto\: :ref:`String<class_String>` = "UDP", duration\: :ref:`int<class_int>` = 0\ ) |const| :ref:`🔗<class_UPNP_method_add_port_mapping>`
Adds a mapping to forward the external ``port`` (between 1 and 65535, although recommended to use port 1024 or above) on the default gateway (see :ref:`get_gateway()<class_UPNP_method_get_gateway>`) to the ``port_internal`` on the local machine for the given protocol ``proto`` (either ``"TCP"`` or ``"UDP"``, with UDP being the default). If a port mapping for the given port and protocol combination already exists on that gateway device, this method tries to overwrite it. If that is not desired, you can retrieve the gateway manually with :ref:`get_gateway()<class_UPNP_method_get_gateway>` and call :ref:`add_port_mapping()<class_UPNP_method_add_port_mapping>` on it, if any. Note that forwarding a well-known port (below 1024) with UPnP may fail depending on the device.
Depending on the gateway device, if a mapping for that port already exists, it will either be updated or it will refuse this command due to that conflict, especially if the existing mapping for that port wasn't created via UPnP or points to a different network address (or device) than this one.
If ``port_internal`` is ``0`` (the default), the same port number is used for both the external and the internal port (the ``port`` value).
The description (``desc``) is shown in some routers management UIs and can be used to point out which application added the mapping.
The mapping's lease ``duration`` can be limited by specifying a duration in seconds. The default of ``0`` means no duration, i.e. a permanent lease and notably some devices only support these permanent leases. Note that whether permanent or not, this is only a request and the gateway may still decide at any point to remove the mapping (which usually happens on a reboot of the gateway, when its external IP address changes, or on some models when it detects a port mapping has become inactive, i.e. had no traffic for multiple minutes). If not ``0`` (permanent), the allowed range according to spec is between ``120`` (2 minutes) and ``86400`` seconds (24 hours).
See :ref:`UPNPResult<enum_UPNP_UPNPResult>` for possible return values.
.. rst-class:: classref-item-separator
----
.. _class_UPNP_method_clear_devices:
.. rst-class:: classref-method
|void| **clear_devices**\ (\ ) :ref:`🔗<class_UPNP_method_clear_devices>`
Efface la liste des appareils découverts.
.. rst-class:: classref-item-separator
----
.. _class_UPNP_method_delete_port_mapping:
.. rst-class:: classref-method
:ref:`int<class_int>` **delete_port_mapping**\ (\ port\: :ref:`int<class_int>`, proto\: :ref:`String<class_String>` = "UDP"\ ) |const| :ref:`🔗<class_UPNP_method_delete_port_mapping>`
Deletes the port mapping for the given port and protocol combination on the default gateway (see :ref:`get_gateway()<class_UPNP_method_get_gateway>`) if one exists. ``port`` must be a valid port between 1 and 65535, ``proto`` can be either ``"TCP"`` or ``"UDP"``. May be refused for mappings pointing to addresses other than this one, for well-known ports (below 1024), or for mappings not added via UPnP. See :ref:`UPNPResult<enum_UPNP_UPNPResult>` for possible return values.
.. rst-class:: classref-item-separator
----
.. _class_UPNP_method_discover:
.. rst-class:: classref-method
:ref:`int<class_int>` **discover**\ (\ timeout\: :ref:`int<class_int>` = 2000, ttl\: :ref:`int<class_int>` = 2, device_filter\: :ref:`String<class_String>` = "InternetGatewayDevice"\ ) :ref:`🔗<class_UPNP_method_discover>`
Découvre les :ref:`UPNPDevice<class_UPNPDevice>`\ s locaux. Efface la liste des appareils précédemment découverts.
Filtre pour les appareils de type IGD (InternetGatewayDevice) par défaut, comme ceux gèrent le suivi de port. ``timeout`` est la durée d'attente des réponses en millisecondes. ``ttl`` est le temps de vie, changez-le seulement si vous savez ce que vous faites.
Voir :ref:`UPNPResult<enum_UPNP_UPNPResult>` pour les valeurs de renvoi possibles.
.. rst-class:: classref-item-separator
----
.. _class_UPNP_method_get_device:
.. rst-class:: classref-method
:ref:`UPNPDevice<class_UPNPDevice>` **get_device**\ (\ index\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_UPNP_method_get_device>`
Renvoie l'appareil :ref:`UPNPDevice<class_UPNPDevice>` à l'``index`` donné.
.. rst-class:: classref-item-separator
----
.. _class_UPNP_method_get_device_count:
.. rst-class:: classref-method
:ref:`int<class_int>` **get_device_count**\ (\ ) |const| :ref:`🔗<class_UPNP_method_get_device_count>`
Renvoie le nombre de :ref:`UPNPDevice<class_UPNPDevice>` découverts.
.. rst-class:: classref-item-separator
----
.. _class_UPNP_method_get_gateway:
.. rst-class:: classref-method
:ref:`UPNPDevice<class_UPNPDevice>` **get_gateway**\ (\ ) |const| :ref:`🔗<class_UPNP_method_get_gateway>`
Renvoie la passerelle par défaut. Il s'agit du premier :ref:`UPNPDevice<class_UPNPDevice>` découvert qui est également un IGD (InternetGatewayDevice) valide.
.. rst-class:: classref-item-separator
----
.. _class_UPNP_method_query_external_address:
.. rst-class:: classref-method
:ref:`String<class_String>` **query_external_address**\ (\ ) |const| :ref:`🔗<class_UPNP_method_query_external_address>`
Renvoie l'adresse :ref:`IP<class_IP>` externe de la passerelle par défaut (voir :ref:`get_gateway()<class_UPNP_method_get_gateway>`) en tant que chaîne. Renvoie une chaîne vide en cas d'erreur.
.. rst-class:: classref-item-separator
----
.. _class_UPNP_method_remove_device:
.. rst-class:: classref-method
|void| **remove_device**\ (\ index\: :ref:`int<class_int>`\ ) :ref:`🔗<class_UPNP_method_remove_device>`
Removes the device at ``index`` from the list of discovered devices.
.. rst-class:: classref-item-separator
----
.. _class_UPNP_method_set_device:
.. rst-class:: classref-method
|void| **set_device**\ (\ index\: :ref:`int<class_int>`, device\: :ref:`UPNPDevice<class_UPNPDevice>`\ ) :ref:`🔗<class_UPNP_method_set_device>`
Sets the device at ``index`` from the list of discovered devices to ``device``.
.. |virtual| replace:: :abbr:`virtual (Cette méthode doit typiquement être redéfinie par l'utilisateur pour avoir un effet.)`
.. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)`
.. |const| replace:: :abbr:`const (Cette méthode n'a pas d'effets de bord. Elle ne modifie aucune des variables membres de l'instance.)`
.. |vararg| replace:: :abbr:`vararg (Cette méthode accepte n'importe quel nombre d'arguments après ceux décris ici.)`
.. |constructor| replace:: :abbr:`constructor (Cette méthode est utilisée pour construire un type.)`
.. |static| replace:: :abbr:`static (Cette méthode n'a pas besoin d'instance pour être appelée, elle peut donc être directement appelée en utilisant le nom de la classe.)`
.. |operator| replace:: :abbr:`operator (Cette méthode décrit un opérateur valide à utiliser avec ce type en tant qu'opérande gauche.)`
.. |bitfield| replace:: :abbr:`BitField (Cette valeur est un nombre entier composé d'un masque de bits des options suivantes.)`
.. |void| replace:: :abbr:`void (Aucune valeur de retour.)`