mdns – Multicast Domain Name Service
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
- ipv4_address: ipaddress.IPv4Address | None
IP v4 Address of the remote service. None if no A records are found.
- 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>.localin addition to
circuitpython.local. Make sure this is unique across all devices on the network. It defaults to
######is the hex digits of the last three bytes of the mac address.
- 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
- advertise_service(*, service_type: str, protocol: str, port: int) None
Respond to queries for the given service with the given port.
protocolcan only occur on one port. Any call after the first will update the entry’s port.