mdns
– Multicast Domain Name Service¶
The mdns
module provides basic support for multicast domain name services.
Basic use provides hostname resolution under the .local TLD. This module
also supports DNS Service Discovery that allows for discovering other hosts
that provide a desired service.
Available on these boards
- class mdns.RemoteService¶
Encapsulates information about a remote service that was found during a search. This object may only be created by a
mdns.Server
. It has no user-visible constructor.Cannot be instantiated directly. Use
mdns.Server.find
.- hostname :str¶
The hostname of the device (read-only),.
- instance_name :str¶
The human readable instance name for the service. (read-only)
- service_type :str¶
The service type string such as
_http
. (read-only)
- protocol :str¶
The protocol string such as
_tcp
. (read-only)
- port :int¶
Port number used for the service. (read-only)
- class mdns.Server(network_interface: wifi.Radio)¶
The MDNS Server responds to queries for this device’s information and allows for querying other devices.
Constructs or returns the mdns.Server for the given network_interface. (CircuitPython may already be using it.) Only native interfaces are currently supported.
- hostname :str¶
Hostname resolvable as
<hostname>.local
in addition tocircuitpython.local
. Make sure this is unique across all devices on the network. It defaults tocpy-######
where######
is the hex digits of the last three bytes of the mac address.
- instance_name :str¶
Human readable name to describe the device.
- find(service_type: str, protocol: str, *, timeout: float = 1) Tuple[RemoteService] ¶
Find all locally available remote services with the given service type and protocol.
This doesn’t allow for direct hostname lookup. To do that, use
socketpool.SocketPool.getaddrinfo()
.