mirror of
https://github.com/nodejs/node.git
synced 2024-11-25 08:19:38 +01:00
3e1b1dd4a9
The copyright and license notice is already in the LICENSE file. There is no justifiable reason to also require that it be included in every file, since the individual files are not individually distributed except as part of the entire package.
36 lines
772 B
JavaScript
36 lines
772 B
JavaScript
var common = require('../common');
|
|
var assert = require('assert');
|
|
var net = require('net');
|
|
|
|
var tcpPort = common.PORT;
|
|
var clientConnected = 0;
|
|
var serverConnected = 0;
|
|
|
|
var server = net.createServer(function(socket) {
|
|
socket.end();
|
|
if (++serverConnected === 4) {
|
|
server.close();
|
|
}
|
|
});
|
|
server.listen(tcpPort, 'localhost', function() {
|
|
function cb() {
|
|
++clientConnected;
|
|
}
|
|
|
|
net.createConnection(tcpPort).on('connect', cb);
|
|
net.createConnection(tcpPort, 'localhost').on('connect', cb);
|
|
net.createConnection(tcpPort, cb);
|
|
net.createConnection(tcpPort, 'localhost', cb);
|
|
|
|
assert.throws(function () {
|
|
net.createConnection({
|
|
port: 'invalid!'
|
|
}, cb);
|
|
});
|
|
});
|
|
|
|
process.on('exit', function() {
|
|
assert.equal(clientConnected, 4);
|
|
});
|
|
|