File tree 1 file changed +18
-0
lines changed
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
95
95
one interface and will add membership to it. To add membership to every
96
96
available interface, call ` addMembership ` multiple times, once per interface.
97
97
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
+
98
116
### socket.address()
99
117
<!-- YAML
100
118
added: v0.1.99
You can’t perform that action at this time.
0 commit comments