diff options
author | James M Snell <jasnell@gmail.com> | 2018-10-18 18:12:59 -0700 |
---|---|---|
committer | Rod Vagg <rod@vagg.org> | 2018-11-28 11:26:47 +1100 |
commit | 32ae851710a30f740aed0522b45fdd9d872c8db6 (patch) | |
tree | bffd32020f87690d80fdfac97aa6fbf61837e082 /doc | |
parent | e7a573a9e287aece608f05fecde900ff82efe2cf (diff) | |
download | node-new-32ae851710a30f740aed0522b45fdd9d872c8db6.tar.gz |
doc: document that addMembership must be called once in a cluster
Fixes: https://github.com/nodejs/node/issues/12572
Refs: https://github.com/nodejs/node/pull/16240
PR-URL: https://github.com/nodejs/node/pull/23746
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Diffstat (limited to 'doc')
-rw-r--r-- | doc/api/dgram.md | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/doc/api/dgram.md b/doc/api/dgram.md index 652e2baadc..38500359f6 100644 --- a/doc/api/dgram.md +++ b/doc/api/dgram.md @@ -95,6 +95,24 @@ Tells the kernel to join a multicast group at the given `multicastAddress` and one interface and will add membership to it. To add membership to every available interface, call `addMembership` multiple times, once per interface. +When sharing a UDP socket across multiple `cluster` workers, the +`socket.addMembership()` function must be called only once or an +`EADDRINUSE` error will occur: + +```js +const cluster = require('cluster'); +const dgram = require('dgram'); +if (cluster.isMaster) { + cluster.fork(); // Works ok. + cluster.fork(); // Fails with EADDRINUSE. +} else { + const s = dgram.createSocket('udp4'); + s.bind(1234, () => { + s.addMembership('224.0.0.114'); + }); +} +``` + ### socket.address() <!-- YAML added: v0.1.99 |