我刚刚在nodejs中创建了这个简单的程序,但我无法将其绑定到我的NIC的ipv6地址。如何将本地ipv6地址绑定到我的node.js程序?
我在API文档阅读下列
将localAddress:本地接口绑定的网络连接。
var http = require('http');
var options = {
hostname: 'www.whatismyipv6.com',
localAddress: '2a01:xxxx:xxxx:xxxx::2' //a real ipv6 address here
};
var req = http.request(options, function(res) {
res.on('data', function (chunk) {
console.log(chunk.toString());
});
});
req.on('error', function(e) {
console.log('ERROR: ' + e.message);
});
req.end();
但是,当我执行程序,我得到这个。请注意ipv4地址。
<head>
<title>WhatIsMyIPv6? (IPv4: xx.xx.xxx.xxx)</title>
<meta name="bitly-verification" content="984886d337a6"/>
</head>
它看起来像nodejs忽略localAddress并直接绑定到ipv4地址。
# node --version
v0.8.0