mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
7bc3e16da1
PR-URL: https://github.com/nodejs/node/pull/55408 Refs: https://github.com/libuv/libuv/pull/4407 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Paolo Insogna <paolo@cowtech.it> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
24 lines
522 B
JavaScript
24 lines
522 B
JavaScript
'use strict';
|
|
const net = require('net');
|
|
|
|
const options = { port: 0, reusePort: true };
|
|
|
|
function checkSupportReusePort() {
|
|
return new Promise((resolve, reject) => {
|
|
const server = net.createServer().listen(options);
|
|
server.on('listening', () => {
|
|
server.close(resolve);
|
|
});
|
|
server.on('error', (err) => {
|
|
console.log('The `reusePort` option is not supported:', err.message);
|
|
server.close();
|
|
reject(err);
|
|
});
|
|
});
|
|
}
|
|
|
|
module.exports = {
|
|
checkSupportReusePort,
|
|
options,
|
|
};
|