mirror of https://github.com/lukechilds/node.git
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.
35 lines
772 B
35 lines
772 B
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);
|
|
});
|
|
|
|
|