1'use strict'; 2const common = require('../common'); 3const assert = require('assert'); 4const dgram = require('dgram'); 5const socket = dgram.createSocket('udp4'); 6const data = ['foo', 'bar', 'baz']; 7 8socket.on('message', common.mustCall((msg, rinfo) => { 9 socket.close(); 10 assert.deepStrictEqual(msg.toString(), data.join('')); 11})); 12 13socket.bind(() => socket.send(data, socket.address().port, 'localhost')); 14