diff options
author | James M Snell <jasnell@gmail.com> | 2018-10-19 04:12:59 +0300 |
---|---|---|
committer | Myles Borins <mylesborins@google.com> | 2018-11-29 19:39:07 +0300 |
commit | 32df77c21f980f927a55edddabf46a626945b260 (patch) | |
tree | 1d8cfdc3d53c905cf8e76ddecd5fb581b4e885ee /doc | |
parent | 9b6b2800e6cf426bba99998ed8f6fb8447594edc (diff) |
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 fd99401868d..6541959d3ad 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 |