1'use strict'; 2 3require('../common'); 4const assert = require('assert'); 5const dgram = require('dgram'); 6const multicastAddress = '224.0.0.114'; 7 8const setup = dgram.createSocket.bind(dgram, { type: 'udp4', reuseAddr: true }); 9 10// addMembership() with valid socket and multicast address should not throw 11{ 12 const socket = setup(); 13 socket.addMembership(multicastAddress); 14 socket.close(); 15} 16 17// dropMembership() without previous addMembership should throw 18{ 19 const socket = setup(); 20 assert.throws( 21 () => { socket.dropMembership(multicastAddress); }, 22 /^Error: dropMembership EADDRNOTAVAIL$/, 23 ); 24 socket.close(); 25} 26 27// dropMembership() after addMembership() should not throw 28{ 29 const socket = setup(); 30 socket.addMembership(multicastAddress); 31 socket.dropMembership(multicastAddress); 32 socket.close(); 33} 34