2 const common = require('../common');
3 const http = require('http');
4 const assert = require('assert');
6 if (!common.hasMultiLocalhost()) {
7 console.log('1..0 # Skipped: platform-specific test.');
11 var server = http.createServer(function(req, res) {
12 console.log('Connect from: ' + req.connection.remoteAddress);
13 assert.equal('127.0.0.2', req.connection.remoteAddress);
15 req.on('end', function() {
16 res.writeHead(200, { 'Content-Type': 'text/plain' });
17 res.end('You are from: ' + req.connection.remoteAddress);
22 server.listen(common.PORT, '127.0.0.1', function() {
23 var options = { host: 'localhost',
27 localAddress: '127.0.0.2' };
29 var req = http.request(options, function(res) {
30 res.on('end', function() {