summaryrefslogtreecommitdiff
path: root/test/simple/test-net-connect-handle-econnrefused.js
blob: e311e137567d0b10fb13ea9d218d66a8c105dc99 (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
var common = require('../common');
var net = require('net');
var assert = require('assert');


// Hopefully nothing is running on common.PORT
var c = net.createConnection(common.PORT);

c.on('connect', function () {
  console.error("connected?!");
  assert.ok(false);
})

var gotError = false;
c.on('error', function (e) {
  console.error("couldn't connect.");
  gotError = true;
  assert.equal(require('constants').ECONNREFUSED, e.errno);
});


process.on('exit', function () {
  assert.ok(gotError);
});