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

* Test listening with different handle and fd * Test listening without callback PR-URL: https://github.com/nodejs/node/pull/11778/ Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
50 lines
907 B
JavaScript
50 lines
907 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const net = require('net');
|
|
|
|
common.refreshTmpDir();
|
|
|
|
function closeServer() {
|
|
return common.mustCall(function() {
|
|
this.close();
|
|
});
|
|
}
|
|
|
|
let counter = 0;
|
|
|
|
// Avoid conflict with listen-handle
|
|
function randomPipePath() {
|
|
return common.PIPE + '-listen-path-' + (counter++);
|
|
}
|
|
|
|
// Test listen(path)
|
|
{
|
|
const handlePath = randomPipePath();
|
|
net.createServer()
|
|
.listen(handlePath)
|
|
.on('listening', closeServer());
|
|
}
|
|
|
|
// Test listen({path})
|
|
{
|
|
const handlePath = randomPipePath();
|
|
net.createServer()
|
|
.listen({path: handlePath})
|
|
.on('listening', closeServer());
|
|
}
|
|
|
|
// Test listen(path, cb)
|
|
{
|
|
const handlePath = randomPipePath();
|
|
net.createServer()
|
|
.listen(handlePath, closeServer());
|
|
}
|
|
|
|
// Test listen(path, cb)
|
|
{
|
|
const handlePath = randomPipePath();
|
|
net.createServer()
|
|
.listen({path: handlePath}, closeServer());
|
|
}
|