class

Matter::MDNS::MulticastSocket

Inherits Reference < Object

MulticastSocket for mDNS communication

Provides UDP multicast I/O on port 5353 for mDNS (Multicast DNS). Supports both IPv4 (224.0.0.251) and IPv6 (ff02::fb) multicast groups.

RFC 6762 §5.1: Multicast DNS uses port 5353 on both IPv4 and IPv6

Constants

Log = ::Log.for("matter.mdns.socket")
MDNS_IPV4_MULTICAST_ADDRESS = "224.0.0.251"

mDNS multicast addresses

MDNS_IPV6_MULTICAST_ADDRESS = "ff02::fb"
MDNS_PORT = 5353_u16
MULTICAST_TTL = 255

TTL for multicast packets (RFC 6762 §11: SHOULD be 255)

Constructors

new(family : Socket::Family = Socket::Family::INET)
Source

Instance methods

close

Close the socket and leave all multicast groups

Source
closed?

Check if socket is closed

Source
family
Source
family=(family : Socket::Family)
Source
join_multicast_group

Join the mDNS multicast group

RFC 6762 §5.1: All mDNS responders and queriers MUST join the multicast group

Source
leave_multicast_group

Leave the mDNS multicast group

Source
multicast_address

Get the multicast address for this socket's family

Source
receive(buffer : Bytes, timeout : Time::Span) : Tuple(Int32, Socket::IPAddress) | Nil

Receive data with a timeout

@param buffer Buffer to receive data into @param timeout Timeout duration @return Tuple of (bytes_received, sender_address) or nil if timeout

Source
receive(buffer : Bytes) : Tuple(Int32, Socket::IPAddress)

Receive data from the multicast group

@param buffer Buffer to receive data into @return Tuple of (bytes_received, sender_address)

Source
send_multicast(data : Bytes) : Int32

Send data to the mDNS multicast group

@param data The DNS packet bytes to send @return Number of bytes sent

Source
socket
Source
socket=(socket : UDPSocket)
Source