11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ciconst common = require('../common');
31cb0ef41Sopenharmony_ciif (common.isWindows)
41cb0ef41Sopenharmony_ci  common.skip('dgram clustering is currently not supported on windows.');
51cb0ef41Sopenharmony_ci
61cb0ef41Sopenharmony_ciconst assert = require('assert');
71cb0ef41Sopenharmony_ciconst cluster = require('cluster');
81cb0ef41Sopenharmony_ciconst dgram = require('dgram');
91cb0ef41Sopenharmony_ci
101cb0ef41Sopenharmony_ciif (cluster.isPrimary) {
111cb0ef41Sopenharmony_ci  cluster.fork().on('exit', common.mustCall((code) => {
121cb0ef41Sopenharmony_ci    assert.strictEqual(code, 0);
131cb0ef41Sopenharmony_ci  }));
141cb0ef41Sopenharmony_ci  return;
151cb0ef41Sopenharmony_ci}
161cb0ef41Sopenharmony_ci
171cb0ef41Sopenharmony_cilet waiting = 2;
181cb0ef41Sopenharmony_cifunction close() {
191cb0ef41Sopenharmony_ci  if (--waiting === 0)
201cb0ef41Sopenharmony_ci    cluster.worker.disconnect();
211cb0ef41Sopenharmony_ci}
221cb0ef41Sopenharmony_ci
231cb0ef41Sopenharmony_ciconst options = { type: 'udp4', reuseAddr: true };
241cb0ef41Sopenharmony_ciconst socket1 = dgram.createSocket(options);
251cb0ef41Sopenharmony_ciconst socket2 = dgram.createSocket(options);
261cb0ef41Sopenharmony_ci
271cb0ef41Sopenharmony_cisocket1.bind(0, () => {
281cb0ef41Sopenharmony_ci  socket2.bind(socket1.address().port, () => {
291cb0ef41Sopenharmony_ci    // Work around health check issue
301cb0ef41Sopenharmony_ci    process.nextTick(() => {
311cb0ef41Sopenharmony_ci      socket1.close(close);
321cb0ef41Sopenharmony_ci      socket2.close(close);
331cb0ef41Sopenharmony_ci    });
341cb0ef41Sopenharmony_ci  });
351cb0ef41Sopenharmony_ci});
36