Skip to content

Instantly share code, notes, and snippets.

@banyudu
Created July 14, 2021 12:07
Show Gist options
  • Select an option

  • Save banyudu/fe940a9b1597c8c56aa5aa58bb22ae84 to your computer and use it in GitHub Desktop.

Select an option

Save banyudu/fe940a9b1597c8c56aa5aa58bb22ae84 to your computer and use it in GitHub Desktop.
nodejs ipv6 ipv4 test
require('http').createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.write('Hello ipv4!\n');
res.end();
}).listen({
port: 9999,
host: '127.0.0.1'
});
require('http').createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.write('Hello ipv6!\n');
res.end();
}).listen({
port: 9999,
host: '::1',
ipv6Only: true
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment