示例:IPv6 输出组播接口


¥Example: IPv6 outgoing multicast interface

在大多数系统上,范围格式使用接口名称:

¥On most systems, where scope format uses the interface name:

const socket = dgram.createSocket('udp6');

socket.bind(1234, () => {
  socket.setMulticastInterface('::%eth1');
}); 

在 Windows 上,范围格式使用接口编号:

¥On Windows, where scope format uses an interface number:

const socket = dgram.createSocket('udp6');

socket.bind(1234, () => {
  socket.setMulticastInterface('::%2');
});