class Matter::MDNS::MulticastSocket

Overview

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

Defined in:

matter/mdns/multicast_socket.cr

Constant Summary

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

Instance Method Summary

Constructor Detail

def self.new(family : Socket::Family = Socket::Family::INET) #

[View source]

Instance Method Detail

def close : Nil #

Close the socket and leave all multicast groups


[View source]
def closed? : Bool #

Check if socket is closed


[View source]
def family : Socket::Family #

[View source]
def family=(family : Socket::Family) #

[View source]
def join_multicast_group : Nil #

Join the mDNS multicast group

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


[View source]
def leave_multicast_group : Nil #

Leave the mDNS multicast group


[View source]
def multicast_address : String #

Get the multicast address for this socket's family


[View source]
def 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


[View source]
def 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)


[View source]
def 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


[View source]
def socket : UDPSocket #

[View source]
def socket=(socket : UDPSocket) #

[View source]