blob: 5b84e3513381d927fd788765166e745941b438fd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
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);
});
|