1'use strict';
2const common = require('../common');
3const dgram = require('dgram');
4
5const buf = Buffer.alloc(1024, 42);
6
7const socket = dgram.createSocket('udp4');
8
9// Get a random port for send
10const portGetter = dgram.createSocket('udp4')
11  .bind(0, 'localhost', common.mustCall(() => {
12    socket.send(buf, 0, buf.length,
13                portGetter.address().port,
14                portGetter.address().address);
15
16    // If close callback is not function, ignore the argument.
17    socket.close('bad argument');
18    portGetter.close();
19
20    socket.on('close', common.mustCall());
21  }));
22