mirror of
https://github.com/nodejs/node.git
synced 2025-05-06 21:35:34 +00:00

If the udp socket is not ready and we are accumulating messages to send, it needs to delay closing the socket when all messages are flushed. Fixes: https://github.com/nodejs/node/issues/7061 PR-URL: https://github.com/nodejs/node/pull/7066 Reviewed-By: Anna Henningsen <anna@addaleax.net>
19 lines
460 B
JavaScript
19 lines
460 B
JavaScript
'use strict';
|
|
// Ensure that if a dgram socket is closed before the sendQueue is drained
|
|
// will not crash
|
|
|
|
const common = require('../common');
|
|
const dgram = require('dgram');
|
|
|
|
const buf = Buffer.alloc(1024, 42);
|
|
|
|
const socket = dgram.createSocket('udp4');
|
|
|
|
socket.on('listening', function() {
|
|
socket.close();
|
|
});
|
|
|
|
// adds a listener to 'listening' to send the data when
|
|
// the socket is available
|
|
socket.send(buf, 0, buf.length, common.PORT, 'localhost');
|