/
githubmirror
/
node
Обзор
Документация
Войти
/
githubmirror
/
node
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
v22.22.3
test/common/net.js
33 строки
826 B
James M Snell
test: move hasMultiLocalhost to common/net
06 фев 2025, 03:10
Не верифицирован
06 фев 2025, 03:10
92e9978
Код
Авторство
О чём код?
'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); }); }); } function hasMultiLocalhost() { const { internalBinding } = require('internal/test/binding'); const { TCP, constants: TCPConstants } = internalBinding('tcp_wrap'); const t = new TCP(TCPConstants.SOCKET); const ret = t.bind('127.0.0.2', 0); t.close(); return ret === 0; } module.exports = { checkSupportReusePort, hasMultiLocalhost, options, };