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.
57 lines
1.3 KiB
57 lines
1.3 KiB
12 years ago
|
var common = require('../common');
|
||
|
var assert = require('assert');
|
||
|
var net = require('net');
|
||
12 years ago
|
var dns = require('dns');
|
||
12 years ago
|
|
||
11 years ago
|
if (!common.hasIPv6) {
|
||
|
console.error('Skipping test, no IPv6 support');
|
||
|
return;
|
||
|
}
|
||
|
|
||
12 years ago
|
var serverGotEnd = false;
|
||
|
var clientGotEnd = false;
|
||
|
|
||
12 years ago
|
dns.lookup('localhost', 6, function(err) {
|
||
|
if (err) {
|
||
|
console.error('Looks like IPv6 is not really supported');
|
||
|
console.error(err);
|
||
|
return;
|
||
|
}
|
||
12 years ago
|
|
||
12 years ago
|
var server = net.createServer({allowHalfOpen: true}, function(socket) {
|
||
|
socket.resume();
|
||
|
socket.on('end', function() {
|
||
|
serverGotEnd = true;
|
||
12 years ago
|
});
|
||
12 years ago
|
socket.end();
|
||
|
});
|
||
|
|
||
|
server.listen(common.PORT, '::1', function() {
|
||
|
var client = net.connect({
|
||
|
host: 'localhost',
|
||
|
port: common.PORT,
|
||
|
family: 6,
|
||
|
allowHalfOpen: true
|
||
|
}, function() {
|
||
|
console.error('client connect cb');
|
||
|
client.resume();
|
||
|
client.on('end', function() {
|
||
|
clientGotEnd = true;
|
||
|
setTimeout(function() {
|
||
|
assert(client.writable);
|
||
|
client.end();
|
||
|
}, 10);
|
||
|
});
|
||
|
client.on('close', function() {
|
||
|
server.close();
|
||
|
});
|
||
12 years ago
|
});
|
||
|
});
|
||
|
|
||
12 years ago
|
process.on('exit', function() {
|
||
|
console.error('exit', serverGotEnd, clientGotEnd);
|
||
|
assert(serverGotEnd);
|
||
|
assert(clientGotEnd);
|
||
|
});
|
||
12 years ago
|
});
|