Documentation
¶
Index ¶
- type UDPConn
- func (c *UDPConn) Close() error
- func (c *UDPConn) Interfaces() []net.Interface
- func (c *UDPConn) JoinMulticastGroup(ifaces []net.Interface, gaddr *net.UDPAddr) error
- func (c *UDPConn) Network() string
- func (c *UDPConn) ReuseAddrPort() error
- func (c *UDPConn) SetMulticastHopLimit(hoplim int) error
- func (c *UDPConn) SetMulticastLoopback(on bool) error
- func (c *UDPConn) SetMulticastTTL(ttl int) error
- func (c *UDPConn) WriteToMulticast(buf []byte, addr *net.UDPAddr) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type UDPConn ¶
UDPConn is a UDP connection configured for multicast communication. It embeds net.UDPConn and provides convenience methods for multicast reads/writes.
func ListenMulticastUDPIfaces ¶
func ListenMulticastUDPIfaces(network string, ifaces []net.Interface, addr *net.UDPAddr) (*UDPConn, error)
ListenMulticastUDPIfaces listens for multicast on the provided address and joins multicast groups on the given network interfaces.
It accepts "udp4" or "udp6" for the network argument. If ifaces is nil, it will use all multicast-capable interfaces. The addr argument specifies the socket to bind to. It returns a *UDPConn ready for multicast reads/writes.
func (*UDPConn) Interfaces ¶
Interfaces returns a copy of the interfaces that have joined the multicast group.
func (*UDPConn) JoinMulticastGroup ¶
JoinMulticastGroup joins the multicast group gaddr on iface. This allows adding additional interfaces to the multicast group dynamically.
Example:
addr := &net.UDPAddr{IP: net.IPv4zero, Port: 0}
conn, err := multicast.ListenMulticastUDPIfaces("udp4", nil, addr)
gaddr := &net.UDPAddr{IP: net.IPv4(224, 0, 0, 251), Port: 5353}
err := conn.JoinMulticastGroup(iface, gaddr)
func (*UDPConn) ReuseAddrPort ¶
func (*UDPConn) SetMulticastHopLimit ¶
SetMulticastHopLimit is an alias to SetMulticastTTL for API symmetry for IPv6.
func (*UDPConn) SetMulticastLoopback ¶
SetMulticastLoopback sets whether multicast packets sent from this socket should be looped back to the local sockets.
func (*UDPConn) SetMulticastTTL ¶
SetMulticastTTL sets the multicast TTL (IPv4) or hop limit (IPv6) used for outbound multicast packets.
func (*UDPConn) WriteToMulticast ¶
WriteToMulticast sends buf to the multicast address addr using all joined interfaces. Any errors encountered during transmission on each interface are aggregated and returned as a joined error.