MCPcopy Index your code
hub / github.com/nodejs/node / worker

Function worker

test/parallel/test-cluster-dgram-1.js:94–111  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

92
93
94function worker() {
95 let received = 0;
96
97 // Create udp socket and start listening.
98 const socket = dgram.createSocket('udp4');
99
100 socket.on('message', common.mustCall((data, info) => {
101 received++;
102
103 // Every 10 messages, notify the primary.
104 if (received === PACKETS_PER_WORKER) {
105 process.send({ received });
106 socket.close();
107 }
108 }, PACKETS_PER_WORKER));
109
110 socket.bind(0);
111}

Callers 1

Calls 5

createSocketMethod · 0.80
sendMethod · 0.65
closeMethod · 0.65
onMethod · 0.45
bindMethod · 0.45

Tested by

no test coverage detected