node/test/simple/test-net-connect-handle-eco...

25 lines
505 B
JavaScript
Raw Normal View History

2010-11-30 09:36:59 +08:00
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);
2010-12-05 06:45:52 +08:00
c.on('connect', function() {
console.error('connected?!');
2010-11-30 09:36:59 +08:00
assert.ok(false);
});
2010-11-30 09:36:59 +08:00
var gotError = false;
2010-12-05 06:45:52 +08:00
c.on('error', function(e) {
console.error('couldn\'t connect.');
2010-11-30 09:36:59 +08:00
gotError = true;
assert.equal(require('constants').ECONNREFUSED, e.errno);
});
2010-12-05 06:45:52 +08:00
process.on('exit', function() {
2010-11-30 09:36:59 +08:00
assert.ok(gotError);
});