mirror of
https://github.com/nodejs/node.git
synced 2024-11-25 08:19:38 +01:00
f57e9c36ab
PR-URL: https://github.com/nodejs/node/pull/46407 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
34 lines
821 B
JavaScript
34 lines
821 B
JavaScript
'use strict';
|
|
|
|
require('../common');
|
|
const assert = require('assert');
|
|
const dgram = require('dgram');
|
|
const multicastAddress = '224.0.0.114';
|
|
|
|
const setup = dgram.createSocket.bind(dgram, { type: 'udp4', reuseAddr: true });
|
|
|
|
// addMembership() with valid socket and multicast address should not throw
|
|
{
|
|
const socket = setup();
|
|
socket.addMembership(multicastAddress);
|
|
socket.close();
|
|
}
|
|
|
|
// dropMembership() without previous addMembership should throw
|
|
{
|
|
const socket = setup();
|
|
assert.throws(
|
|
() => { socket.dropMembership(multicastAddress); },
|
|
/^Error: dropMembership EADDRNOTAVAIL$/,
|
|
);
|
|
socket.close();
|
|
}
|
|
|
|
// dropMembership() after addMembership() should not throw
|
|
{
|
|
const socket = setup();
|
|
socket.addMembership(multicastAddress);
|
|
socket.dropMembership(multicastAddress);
|
|
socket.close();
|
|
}
|