|
@ -2,16 +2,12 @@ |
|
|
const common = require('../common'); |
|
|
const common = require('../common'); |
|
|
const assert = require('assert'); |
|
|
const assert = require('assert'); |
|
|
const net = require('net'); |
|
|
const net = require('net'); |
|
|
const dns = require('dns'); |
|
|
|
|
|
|
|
|
|
|
|
if (!common.hasIPv6) { |
|
|
if (!common.hasIPv6) { |
|
|
console.log('1..0 # Skipped: no IPv6 support'); |
|
|
console.log('1..0 # Skipped: no IPv6 support'); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var serverGotEnd = false; |
|
|
|
|
|
var clientGotEnd = false; |
|
|
|
|
|
|
|
|
|
|
|
const hosts = common.localIPv6Hosts; |
|
|
const hosts = common.localIPv6Hosts; |
|
|
var hostIdx = 0; |
|
|
var hostIdx = 0; |
|
|
var host = hosts[hostIdx]; |
|
|
var host = hosts[hostIdx]; |
|
@ -19,9 +15,7 @@ var localhostTries = 10; |
|
|
|
|
|
|
|
|
const server = net.createServer({allowHalfOpen: true}, function(socket) { |
|
|
const server = net.createServer({allowHalfOpen: true}, function(socket) { |
|
|
socket.resume(); |
|
|
socket.resume(); |
|
|
socket.on('end', function() { |
|
|
socket.on('end', common.mustCall(function() {})); |
|
|
serverGotEnd = true; |
|
|
|
|
|
}); |
|
|
|
|
|
socket.end(); |
|
|
socket.end(); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
@ -36,13 +30,12 @@ function tryConnect() { |
|
|
}, function() { |
|
|
}, function() { |
|
|
console.error('client connect cb'); |
|
|
console.error('client connect cb'); |
|
|
client.resume(); |
|
|
client.resume(); |
|
|
client.on('end', function() { |
|
|
client.on('end', common.mustCall(function() { |
|
|
clientGotEnd = true; |
|
|
|
|
|
setTimeout(function() { |
|
|
setTimeout(function() { |
|
|
assert(client.writable); |
|
|
assert(client.writable); |
|
|
client.end(); |
|
|
client.end(); |
|
|
}, 10); |
|
|
}, 10); |
|
|
}); |
|
|
})); |
|
|
client.on('close', function() { |
|
|
client.on('close', function() { |
|
|
server.close(); |
|
|
server.close(); |
|
|
}); |
|
|
}); |
|
@ -54,7 +47,6 @@ function tryConnect() { |
|
|
tryConnect(); |
|
|
tryConnect(); |
|
|
else { |
|
|
else { |
|
|
console.log('1..0 # Skipped: no IPv6 localhost support'); |
|
|
console.log('1..0 # Skipped: no IPv6 localhost support'); |
|
|
process.removeListener('exit', onExit); |
|
|
|
|
|
server.close(); |
|
|
server.close(); |
|
|
} |
|
|
} |
|
|
return; |
|
|
return; |
|
@ -62,10 +54,3 @@ function tryConnect() { |
|
|
throw err; |
|
|
throw err; |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
process.on('exit', onExit); |
|
|
|
|
|
function onExit() { |
|
|
|
|
|
console.error('exit', serverGotEnd, clientGotEnd); |
|
|
|
|
|
assert(serverGotEnd); |
|
|
|
|
|
assert(clientGotEnd); |
|
|
|
|
|
} |
|
|
|
|
|