2015-05-19 19:00:06 +08:00
|
|
|
'use strict';
|
2012-07-14 03:11:38 +08:00
|
|
|
var common = require('../common');
|
|
|
|
var assert = require('assert');
|
|
|
|
var net = require('net');
|
|
|
|
|
|
|
|
var client, killed = false, ended = false;
|
2015-05-19 19:00:06 +08:00
|
|
|
var TIMEOUT = 10 * 1000;
|
2012-07-14 03:11:38 +08:00
|
|
|
|
|
|
|
client = net.createConnection(53, '8.8.8.8', function() {
|
|
|
|
client.unref();
|
|
|
|
});
|
|
|
|
|
|
|
|
client.on('close', function() {
|
|
|
|
ended = true;
|
|
|
|
});
|
|
|
|
|
|
|
|
setTimeout(function() {
|
|
|
|
killed = true;
|
|
|
|
client.end();
|
|
|
|
}, TIMEOUT).unref();
|
|
|
|
|
|
|
|
process.on('exit', function() {
|
|
|
|
assert.strictEqual(killed, false, 'A client should have connected');
|
|
|
|
assert.strictEqual(ended, false, 'A client should stay connected');
|
|
|
|
});
|