File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -95,6 +95,24 @@ Tells the kernel to join a multicast group at the given `multicastAddress` and
9595one interface and will add membership to it. To add membership to every
9696available interface, call ` addMembership ` multiple times, once per interface.
9797
98+ When sharing a UDP socket across multiple ` cluster ` workers, the
99+ ` socket.addMembership() ` function must be called only once or an
100+ ` EADDRINUSE ` error will occur:
101+
102+ ``` js
103+ const cluster = require (' cluster' );
104+ const dgram = require (' dgram' );
105+ if (cluster .isMaster ) {
106+ cluster .fork (); // Works ok.
107+ cluster .fork (); // Fails with EADDRINUSE.
108+ } else {
109+ const s = dgram .createSocket (' udp4' );
110+ s .bind (1234 , () => {
111+ s .addMembership (' 224.0.0.114' );
112+ });
113+ }
114+ ```
115+
98116### socket.address()
99117<!-- YAML
100118added: v0.1.99
You can’t perform that action at this time.
0 commit comments