mirror of
https://github.com/nodejs/node.git
synced 2025-05-04 15:02:25 +00:00

inFreeBSDJail involves an execSync() and is used by localhost_ipv4 so will be unnecessarily expensive, so cache both values and reuse rather than re-evaluate each time. Renamed localhost_ipv4 to localhostIPv4 for style consistency. PR-URL: https://github.com/iojs/io.js/pull/1196 Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
27 lines
637 B
JavaScript
27 lines
637 B
JavaScript
var common = require('../common');
|
|
var assert = require('assert');
|
|
var net = require('net');
|
|
|
|
var conns = 0, conns_closed = 0;
|
|
|
|
var server = net.createServer(function(socket) {
|
|
conns++;
|
|
assert.equal(common.localhostIPv4, socket.localAddress);
|
|
assert.equal(socket.localPort, common.PORT);
|
|
socket.on('end', function() {
|
|
server.close();
|
|
});
|
|
socket.resume();
|
|
});
|
|
|
|
server.listen(common.PORT, common.localhostIPv4, function() {
|
|
var client = net.createConnection(common.PORT, common.localhostIPv4);
|
|
client.on('connect', function() {
|
|
client.end();
|
|
});
|
|
});
|
|
|
|
process.on('exit', function() {
|
|
assert.equal(1, conns);
|
|
});
|