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
Registers a listener for the given event.
Events:
'message' — emitted when a UDP message is received. 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.'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. 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.'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. 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.'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. 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.'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
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.
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. 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).
whether to enable multicast loopback
Sets both the unicast TTL and the multicast TTL on the underlying multicast socket.
the time-to-live value (1-255)
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.