You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
478 B
21 lines
478 B
const net = require('net'); |
|
|
|
exports = function(port, host) { |
|
return new Promise(resolve => { |
|
const server = net.createServer(); |
|
|
|
server.unref(); |
|
server.on('error', () => resolve(false)); |
|
const options = { |
|
port |
|
}; |
|
if (host) options.host = host; |
|
server.listen(options, () => { |
|
server.close(() => { |
|
resolve(true); |
|
}); |
|
}); |
|
}); |
|
}; |
|
|
|
module.exports = exports;
|
|
|