ProtectedconstructorProtectedthe options used to create this socket
the detected UDP socket type ('udp4' or 'udp6')
the resolved network interfaces as parsed IP address objects
the resolved interface addresses as plain strings (without CIDR prefix)
the underlying dgram socket bound to 0.0.0.0 or :: for group traffic
a map of interface address to its dedicated dgram unicast socket
Readonlyaddressesthe resolved interface addresses as plain strings (without CIDR prefix)
Readonlyinterfacesthe resolved network interfaces as parsed IP address objects
Protected Readonlymulticastthe underlying dgram socket bound to 0.0.0.0 or :: for group traffic
Readonlyoptionsthe options used to create this socket
Protected Readonlytypethe detected UDP socket type ('udp4' or 'udp6')
Protected Readonlyunicasta map of interface address to its dedicated dgram unicast socket
Returns the address information for all underlying sockets (the multicast socket plus each per-interface unicast socket).
Each entry contains address, family, and port properties.
Closes all underlying sockets and stops listening for data. Drops multicast group membership on each interface before closing the multicast socket.
Prefer destroy for full cleanup, which also removes all event listeners.
Closes all underlying sockets and removes all event listeners from both the internal dgram sockets and this MulticastSocket instance. This is the recommended way to fully tear down a socket.
Removes a previously registered listener for the given event.
the event name
the callback to remove
Removes a previously registered listener for the given event.
the event name
the callback to remove
Removes a previously registered listener for the given event.
the event name
the callback to remove
Removes a previously registered listener for the given event.
the event name
the callback to remove
Removes a previously registered listener for the given event.
the event name
the callback to remove
Registers a listener for the given event.
Events:
'message': emitted when a UDP message is received and passes all inbound
filters. The listener receives the raw message buffer, the local
AddressInfo of the receiving socket, the RemoteInfo of the
sender, and a fromSelf boolean indicating whether the message originated
from this instance.'drop': emitted when an inbound message is rejected by a filter. Currently
the only reason is 'off-link' (RFC 6762 §11 link-local origin check failed
while options.linkLocalOnly was true). The listener receives the message,
the local address, the remote address, and the reason string.'close': emitted when an underlying socket is closed.'connect': emitted when an underlying socket connects.'error': emitted when an underlying socket encounters an error.the event name
the callback to invoke when the event is emitted
Registers a listener for the given event.
Events:
'message': emitted when a UDP message is received and passes all inbound
filters. The listener receives the raw message buffer, the local
AddressInfo of the receiving socket, the RemoteInfo of the
sender, and a fromSelf boolean indicating whether the message originated
from this instance.'drop': emitted when an inbound message is rejected by a filter. Currently
the only reason is 'off-link' (RFC 6762 §11 link-local origin check failed
while options.linkLocalOnly was true). The listener receives the message,
the local address, the remote address, and the reason string.'close': emitted when an underlying socket is closed.'connect': emitted when an underlying socket connects.'error': emitted when an underlying socket encounters an error.the event name
the callback to invoke when the event is emitted
Registers a listener for the given event.
Events:
'message': emitted when a UDP message is received and passes all inbound
filters. The listener receives the raw message buffer, the local
AddressInfo of the receiving socket, the RemoteInfo of the
sender, and a fromSelf boolean indicating whether the message originated
from this instance.'drop': emitted when an inbound message is rejected by a filter. Currently
the only reason is 'off-link' (RFC 6762 §11 link-local origin check failed
while options.linkLocalOnly was true). The listener receives the message,
the local address, the remote address, and the reason string.'close': emitted when an underlying socket is closed.'connect': emitted when an underlying socket connects.'error': emitted when an underlying socket encounters an error.the event name
the callback to invoke when the event is emitted
Registers a listener for the given event.
Events:
'message': emitted when a UDP message is received and passes all inbound
filters. The listener receives the raw message buffer, the local
AddressInfo of the receiving socket, the RemoteInfo of the
sender, and a fromSelf boolean indicating whether the message originated
from this instance.'drop': emitted when an inbound message is rejected by a filter. Currently
the only reason is 'off-link' (RFC 6762 §11 link-local origin check failed
while options.linkLocalOnly was true). The listener receives the message,
the local address, the remote address, and the reason string.'close': emitted when an underlying socket is closed.'connect': emitted when an underlying socket connects.'error': emitted when an underlying socket encounters an error.the event name
the callback to invoke when the event is emitted
Registers a listener for the given event.
Events:
'message': emitted when a UDP message is received and passes all inbound
filters. The listener receives the raw message buffer, the local
AddressInfo of the receiving socket, the RemoteInfo of the
sender, and a fromSelf boolean indicating whether the message originated
from this instance.'drop': emitted when an inbound message is rejected by a filter. Currently
the only reason is 'off-link' (RFC 6762 §11 link-local origin check failed
while options.linkLocalOnly was true). The listener receives the message,
the local address, the remote address, and the reason string.'close': emitted when an underlying socket is closed.'connect': emitted when an underlying socket connects.'error': emitted when an underlying socket encounters an error.the event name
the callback to invoke when the event is emitted
Registers a one-time listener for the given event. The listener is automatically removed after it fires once.
the event name
the callback to invoke when the event is emitted
Registers a one-time listener for the given event. The listener is automatically removed after it fires once.
the event name
the callback to invoke when the event is emitted
Registers a one-time listener for the given event. The listener is automatically removed after it fires once.
the event name
the callback to invoke when the event is emitted
Registers a one-time listener for the given event. The listener is automatically removed after it fires once.
the event name
the callback to invoke when the event is emitted
Registers a one-time listener for the given event. The listener is automatically removed after it fires once.
the event name
the callback to invoke when the event is emitted
Adds all underlying sockets back to the Node.js event loop reference count, restoring the default behavior where the process will not exit while the sockets are open.
Call this to undo a previous unref call.
Sends a message to the multicast group (or a unicast destination).
Socket selection:
options.srcAddress is set, only the unicast socket for that address is used.options.useMulticastSocket is set, the shared multicast socket is used instead.
When combined with options.srcAddress, the multicast interface is set accordingly;
without it, the OS chooses the outgoing interface, which may not cover all interfaces.Destination:
options.dstAddress and/or options.dstPort to send via unicast
or to a different port.Partial failures are collected rather than thrown. Use Promise.allSettled semantics internally so that a failure on one interface does not prevent sending on others.
Concurrency note: combining useMulticastSocket: true with srcAddress mutates per-socket
interface state on the shared multicast socket via setMulticastInterface. Two such calls
issued without awaiting the first to complete will race and may send on the wrong
interface. Serialize them in the caller, or omit useMulticastSocket (the default
per-interface unicast path is race-free because each interface has its own socket).
the payload to send
optional send configuration
an array of errors for any interfaces that failed to send (empty on full success)
Sets or clears the IP_MULTICAST_LOOP socket option on the shared multicast socket.
When set to true, multicast packets sent by this instance will also be delivered to
its own 'message' event listeners (with fromSelf set to true).
Implementation note: this only mutates IP_MULTICAST_LOOP on the shared multicast
socket; the per-interface unicast sockets retain their OS-default loopback. The
authoritative gate for whether the caller sees its own packets is the
loopback check inside dispatch_message, which reads options.loopback that
this method updates. The user-visible contract is therefore honored regardless of
the kernel-level state on the unicast sockets.
whether to enable multicast loopback
Excludes all underlying sockets from the Node.js event loop reference count, allowing the process to exit even if the sockets are still open.
Call ref to restore the default behavior.
StaticcreateAsync factory that creates, binds, and returns a new MulticastSocket.
Internally this creates one multicast dgram socket bound to 0.0.0.0 (or :: for IPv6)
for group traffic, plus one unicast dgram socket per network interface for reliable
multi-interface sending and receiving.
The socket type (udp4 or udp6) is automatically detected from the
multicastGroup address provided in options.
The host option controls which interfaces are used:
0.0.0.0 / ::)the configuration for the new socket
a fully initialized MulticastSocket ready to send and receive
Creates a new instance of a MulticastSocket. Use MulticastSocket.create instead of calling this constructor directly.