{"id":5747,"date":"2023-11-26T13:50:38","date_gmt":"2023-11-26T12:50:38","guid":{"rendered":"https:\/\/dmesg.app\/?p=5747"},"modified":"2023-11-26T13:50:38","modified_gmt":"2023-11-26T12:50:38","slug":"nodejs-dual-stack","status":"publish","type":"post","link":"https:\/\/dmesg.app\/nodejs-dual-stack.html","title":{"rendered":"Node.js 18\u5347\u7ea7\uff1a\u53cc\u6808\u534f\u8bae\u8e29\u5751"},"content":{"rendered":"<p>\u5f88\u4e45\u4e4b\u524d\u6211\u5c31\u53d1\u73b0\u4e86\u4e00\u4e2a\u73b0\u8c61\uff0c\u6709\u4e9b\u65f6\u5019\u6211\u5728\u4f7f\u7528 nc\u53bb\u63a2\u6d4b\u672c\u5730\u7684\u67d0\u4e9b\u670d\u52a1\u662f\u5426\u5f00\u542f\u65f6\uff0c\u4f1a\u6709\u4e24\u4e2a\u8f93\u51fa\uff0c\u7b2c\u4e00\u6b21\u62d2\u7edd\u7b2c\u4e8c\u6b21\u6210\u529f\uff0c\u8f93\u51fa\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<pre class=\"prettyprint linenums\">$ nc -v localhost 12345\r\n\r\nnc: connectx to localhost port 12345 (tcp) failed: Connection refused\r\nConnection to localhost port 12345 [tcp\/italk] succeeded!\r\n<\/pre>\n<p>\u5f88\u5947\u602a\uff0c\u4f46\u662f\u53c8\u4e0d\u662f\u4e0d\u80fd\u7528\uff0c\u5c31\u4e00\u76f4\u6ca1\u53bb\u6df1\u7a76\uff0c\u751a\u81f3\u8fde\u4e00\u70b9\u70b9\u601d\u8003\u90fd\u6ca1\u6709\u3002<\/p>\n<p>\u524d\u51e0\u5929\u5728\u628a\u9879\u76ee\u7684 Node.js \u4ece16\u5347\u7ea7\u523018\u65f6\uff0c\u7a81\u7136\u53d1\u73b0\u80fd\u7528 redbird \u8fde\u4e0d\u4e0a\u540e\u7aef\u7684\u4e00\u4e2a\u670d\u52a1\u4e86\u3002<\/p>\n<p>\u4e8e\u662f\u6211\u5c31\u7ee7\u7eed <code>nc<\/code> \u4e86\u4e00\u4e0b\uff0c<del>\u4f7f\u7528 nc \u662f\u4f5c\u4e3a<s>\u7f51\u7edc\u5de5\u7a0b\u5e08<\/s>\u7684\u57fa\u672c\u6280\u80fd<\/del>\u3002\u7ed3\u679c\u8f93\u51fa\u548c\u4e0a\u9762\u4e00\u6837\uff0c\u7b2c\u4e00\u6b21\u62d2\u7edd\u7b2c\u4e8c\u6b21\u6210\u529f\u3002<\/p>\n<p>\u60f3\u4e86\u51e0\u5206\u949f\u7a81\u7136\u61c2\u4e86\uff0c\u6211\u7684\u670d\u52a1\u53ea\u76d1\u542c\u5728\u4e86 IPv4\u7684\u5730\u5740\uff0c\u5e76\u6ca1\u6709\u76d1\u542c IPv6\u7684\u5730\u5740\uff0c\u800c<code>localhost<\/code> \u901a\u5e38\u4f1a\u540c\u65f6\u89e3\u6790\u4e3a IPv6\u7684\u672c\u5730\u73af\u56de\u5730\u5740 <code>::1 <\/code>\u548c IPv4\u7684<code>127.0.0.1<\/code> \u3002\u540c\u65f6\u5bf9\u4e8e\u5927\u90e8\u5206\u5e94\u7528\u7a0b\u5e8f\u800c\u8a00\uff0c\u5728\u53cc\u6808\u7684\u60c5\u51b5\u4e0b\u4f1a\u4f18\u5148\u5c1d\u8bd5 IPv6\uff0c\u5982\u679c\u5931\u8d25\u90a3\u4e48\u518d\u56de\u843d\u5230 IPv4.<\/p>\n<pre class=\"prettyprint linenums\">$ ping localhost\r\n\r\nPING localhost (127.0.0.1): 56 data bytes\r\n64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.115 ms\r\n^C\r\n--- localhost ping statistics ---\r\n1 packets transmitted, 1 packets received, 0.0% packet loss\r\nround-trip min\/avg\/max\/stddev = 0.115\/0.115\/0.115\/nan ms\r\n\r\n\r\nbenny@Yogurt ~\r\n$ ping6 localhost\r\nPING6(56=40+8+8 bytes) ::1 --&gt; ::1\r\n16 bytes from ::1, icmp_seq=0 hlim=64 time=0.053 ms\r\n<\/pre>\n<p>\u5f53\u65f6\u4e5f\u6ca1\u591a\u60f3\uff0c\u731c\u6d4b\u5c31\u662f redbird \u7531\u4e8e\u4ec0\u4e48\u539f\u56e0\u53ea\u5c1d\u8bd5\u4e86 IPv6 \u7684\u5730\u5740\u3002\u90a3\u5c31\u7b80\u5355\u70b9\u6539 hosts \u8ba9 <code>localhost<\/code> \u53ea\u89e3\u6790\u5230 <code>127.0.0.1<\/code>\u5c31\u597d\u4e86\u3002<br \/>\n<div id=\"sc_tips\">\u53ef\u662f\u6211\u6ca1\u6709 IPv6\u5730\u5740\u5440\uff1f<br \/>\n\u6ca1\u5173\u7cfb\uff0c\u5373\u4fbf\u4f60\u6ca1\u6709\u88ab\u5206\u914dIPv6\u5730\u5740\uff0c\u53ea\u8981\u6ca1\u6709\u660e\u786e\u7981\u7528IPv6\uff0c\u5982 net.ipv6.conf.all.disable_ipv6 = 1 \u90a3\u4e48 ::1 \u7b49\u5c31\u662f\u6709\u7684\uff01<br \/>\n<\/div><\/p>\n<p>\u8fd9\u6837\u6539 hosts \u786e\u5b9e\u7ba1\u7528\uff0c\u4f46\u662f\u77e5\u5176\u7136\uff0c\u66f4\u8981\u77e5\u5176\u6240\u4ee5\u7136\u2026\u2026<\/p>\n<p>\u5728\u5f00\u59cb\u4e4b\u524d\uff0c\u6211\u4eec\u9700\u8981\u4e86\u89e3\u51e0\u4e2a\u6982\u5ff5<\/p>\n<h2>127.0.0.1 \u4e0e ::1<\/h2>\n<p>\u4e3a\u8868\u793a\u672c\u5730\u8ba1\u7b97\u673a\u6240\u4fdd\u7559\u7684IP\u5730\u5740\uff0c\u5bf9\u4e8e IPv4\u800c\u8a00\uff0c\u5176\u8303\u56f4\u662f <code>127.0.0.0\/8<\/code>\uff0c\u5176\u5730\u5740\u8303\u56f4\u4e3a <code>127.0.0.0<\/code> \uff5e <code>127.255.255.255<\/code>\uff0c\u9664\u53bb\u5f00\u5934\u76840\u8868\u793a\u7f51\u7edc\u4f4d\u548c\u7ed3\u5c3e255\u8868\u793a\u5e7f\u64ad\u5730\u5740\uff0c\u5176\u4f59\u6240\u6709\u5730\u5740\u90fd\u53ef\u4ee5\u8868\u793a\u672c\u673a\u3002<\/p>\n<pre class=\"prettyprint linenums\">~: ping 127.255.255.254\r\n\r\nPING 127.255.255.254 (127.255.255.254) 56(84) bytes of data.\r\n64 bytes from 127.255.255.254: icmp_seq=1 ttl=64 time=0.028 ms\r\n^C\r\n--- 127.255.255.254 ping statistics ---\r\n1 packets transmitted, 1 received, 0% packet loss, time 0ms\r\nrtt min\/avg\/max\/mdev = 0.028\/0.028\/0.028\/0.000 ms\r\n\r\n\r\n~: ping 127.8.9.2\r\nPING 127.8.9.2 (127.8.9.2) 56(84) bytes of data.\r\n64 bytes from 127.8.9.2: icmp_seq=1 ttl=64 time=0.045 ms\r\n64 bytes from 127.8.9.2: icmp_seq=2 ttl=64 time=0.039 ms\r\n<\/pre>\n<p>\u81f3\u5c11\u5728 Linux\u4e0b\u662f\u8fd9\u6837\u7684\uff01<code>127.0.0.1<\/code>\u662f\u5e38\u7528\u7684\u6807\u51c6\u73af\u56de\u5730\u5740\uff0c\u5176\u4ed6\u5730\u5740\u5e76\u4e0d\u662f\u6240\u6709\u64cd\u4f5c\u7cfb\u7edf\u90fd\u652f\u6301\u3002<\/p>\n<p>\u5bf9\u4e8e IPv6 \u6765\u8bf4\uff0c\u4e8b\u60c5\u5c31\u7b80\u5355\u4e86\uff0c\u4e00\u4e2a <code>::1<\/code> \u6ca1\u6709\u5176\u4ed6\u7684\u82b1\u6837\u3002<\/p>\n<p>\u5982\u679c\u6211\u4eec\u7684\u5e94\u7528\u7a0b\u5e8f\u76d1\u542c\u5728 <code>127.0.0.1<\/code>\uff0c\u90a3\u4e48\u610f\u5473\u7740\u53ea\u6709\u672c\u673a\uff0c\u66f4\u51c6\u786e\u7684\u8bf4\u6765\u81ea\u4e8e <code>127.0.0.1<\/code> \u7684\u8bf7\u6c42\u624d\u4f1a\u88ab\u63a5\u53d7\uff1b\u7c7b\u4f3c\u5730\uff0c\u76d1\u542c\u5728 <code>::1<\/code> \u4e5f\u662f\u4e00\u6837\uff0c\u610f\u5473\u7740\u53ea\u6709\u6765\u81ea <code>::1<\/code> \u7684\u8bf7\u6c42\u624d\u4f1a\u88ab\u63a5\u53d7\u3002<\/p>\n<p>\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528 nc\u6765\u505a\u8fd9\u6837\u4e00\u4e2a\u5b9e\u9a8c\uff0ck\u8868\u793a\u8fde\u63a5\u540e\u4e0d\u65ad\u5f00\uff0cl\u8868\u793alisten<\/p>\n<pre class=\"prettyprint linenums\">nc -klv 127.0.0.1 12345\r\n<\/pre>\n<p>\u7136\u540e\u53e6\u5f00\u4e00\u4e2a\u7a97\u53e3 <code>nc -v 127.0.0.1 12345<\/code><\/p>\n<pre class=\"prettyprint linenums\">$ nc -v 127.0.0.1 12345\r\nConnection to 127.0.0.1 port 12345 [tcp\/italk] succeeded!\r\n^C\r\n\r\n\r\nbenny@Yogurt: ~\r\n$ nc -v ::1 12345\r\nnc: connectx to ::1 port 12345 (tcp) failed: Connection refused\r\n<\/pre>\n<p>\u4f60\u770b\uff0c\u867d\u7136\u90fd\u662f\u4e00\u53f0\u7535\u8111\uff0c\u4f46\u662f <code>::1<\/code> \u5374\u4e0d\u884c\uff0c\u5982\u679c\u4f60\u6709 docker\uff0c<code>docker0<\/code>\u7f51\u6865\u7684\u5730\u5740\u662f<code>172.17.0.1<\/code>\uff0c\u5f00\u4e2a\u5bb9\u5668\u8bd5\u8bd5<\/p>\n<pre class=\"prettyprint linenums\">~ # ping 172.17.0.1\r\nPING 172.17.0.1 (172.17.0.1): 56 data bytes\r\n64 bytes from 172.17.0.1: seq=0 ttl=64 time=0.213 ms\r\n^C\r\n--- 172.17.0.1 ping statistics ---\r\n1 packets transmitted, 1 packets received, 0% packet loss\r\nround-trip min\/avg\/max = 0.213\/0.213\/0.213 ms\r\n\r\n\r\n~ # nc -vv 172.17.0.1 12345\r\nnc: 172.17.0.1 (172.17.0.1:12345): Connection refused\r\nsent 0, rcvd 0\r\n<\/pre>\n<p>\u4e5f\u4e0d\u884c\uff01\u56e0\u4e3a\u8bf7\u6c42\u4e0d\u662f\u4ece 127 \u6765\u7684\u800c\u662f172\uff01\u5982\u679c\u60f3\u8981\u4ece\u5bb9\u5668\u5185\u53ef\u4ee5\u8bbf\u95ee\uff0c\u90a3\u4e48nc\u5c31\u8981\u76d1\u542c\u5728\u7f51\u6865\u7684\u5730\u5740\uff0c\u5982 <code>nc -klv 172.17.0.1<\/code><\/p>\n<div  class=\"sc_act\">\u54b1\u4e5f\u4e0d\u77e5\u9053\u4e3a\u5565\u8981\u7ed9loopback\u5206\u914d\u90a3\u4e48\u591a\u5730\u5740\uff0c\u80fd\u628a\u8fd9\u4e9b\u62ff\u51fa\u6765\u505a\u5176\u4ed6\u7684\u7528\u9014\u53ef\u80fd\u4f1a\u66f4\u6709\u8da3\u3002<\/div>\n<h2>0.0.0.0\u4e0e ::<\/h2>\n<div  class=\"sc_act\">\u8fd9\u91cc\u7684 0.0.0.0 \u4e0d\u662f\u5728\u6307\u9ed8\u8ba4\u8def\u7531\uff0c\u6307\u7684\u662f\u672c\u673a\u6240\u6709\u7684 IPv4\u5730\u5740\uff0c:: \u7c7b\u4f3c\u5730\u6307\u7684\u662f\u672c\u673a\u6240\u6709\u7684IPv6 \u5730\u5740\u3002<\/div>\n<p>\u5f53\u4f60\u7684\u5e94\u7528\u76d1\u542c\u5728 <code>0.0.0.0<\/code>\u65f6\uff0c\u6240\u6709\u7684\u53ef\u8fbe\u7684IPv4\u5730\u5740\u90fd\u53ef\u4ee5\u8bbf\u95ee\u5230\u3002\u6bd4\u5982\u8bf4\uff0c\u672c\u673a\uff0cdocker \u5bb9\u5668\uff0c\u4f60\u7684\u8def\u7531\u5668\u7b49\u7b49\u90fd\u53ef\u4ee5\u3002\u6211\u4eec\u53ef\u4ee5\u8bd5\u8bd5\u770b<code>nc -klv 0.0.0.0 12345<\/code><\/p>\n<h3>\u4eceMacBook\u8fde\u5230 PVE \u7684\u865a\u62df\u673a<\/h3>\n<pre class=\"prettyprint linenums\">[18:17:02] benny:~ $ nc -v 192.168.7.55 12345\r\nConnection to 192.168.7.55 port 12345 [tcp\/italk] succeeded!\r\n<\/pre>\n<h3>\u4ecePVE\u7684\u865a\u62df\u673a\u7684\u5bb9\u5668\u8fde\u7f51\u6865<\/h3>\n<pre class=\"prettyprint linenums\">~ # cat \/etc\/issue\r\nWelcome to Alpine Linux 3.18\r\nKernel \\r on an \\m (\\l)\r\n\r\n~ # nc -v 172.17.0.1 12345\r\n172.17.0.1 (172.17.0.1:12345) open\r\n<\/pre>\n<p>\u5662\uff01\u6709\u4e00\u70b9\u9700\u8981\u6ce8\u610f\uff0c\u5982\u679c\u4f60\u662f macOS\u6216\u8005Windows\u7684\u8bdd\uff0c\u7531\u4e8e\u8fd9\u4e24\u8005\u5e76\u4e0d\u539f\u751f\u652f\u6301 docker\uff0c\u6240\u4ee5\u4ed6\u4eec\u7684docker\u5b9e\u9645\u4e0a\u662f\u8dd1\u5728\u865a\u62df\u673a\u91cc\u7684\u3002\u6b64\u65f6\u4f60 <code>nc -v 172.17.0.1 <\/code>\u4e5f\u662f\u4e0d\u884c\u7684\uff0c\u56e0\u4e3a\u8fd9\u91cc<code>172.17.0.1<\/code> \u4ee3\u8868\u7684\u662f\u865a\u62df\u673a\u7684\u7f51\u6865\uff0c\u800c\u4e0d\u662f\u4f60\u7684\u7535\u8111\u7684\u7f51\u6865\u3002\u6b64\u65f6\u4f60\u9700\u8981 <code>host.docker.internal<\/code>\u8fd9\u4e2a\u5185\u90e8\u57df\u540d\u3002<br \/>\n<div id=\"sc_blue\">Windows \u7684\u8bdd\uff0c\u5177\u4f53\u60c5\u51b5\u6211\u6ca1\u6d4b\u8bd5\uff0c\u56e0\u4e3a\u6709 Hyper V\u548cWSL\u4e24\u79cd\u60c5\u51b5\u3002<\/div><\/p>\n<h3>\u5982\u679c\u6b64\u65f6\u6211\u4eec\u5728\u672c\u673a\u901a\u8fc7 <code>::1<\/code> \u5c1d\u8bd5\u8fde\u63a5<\/h3>\n<pre class=\"prettyprint linenums\">~ \u27a4 nc -v ::1 12345\r\nnc: connectx to ::1 port 12345 (tcp) failed: Connection refused\r\n<\/pre>\n<p>\u5f53\u7136\u4e0d\u884c\u4e86\uff0cnc\u90fd\u660e\u786e\u6307\u660e\u53ea\u76d1\u542c IPv4\u7684\uff0c\u90a3\u4e48\u901a\u8fc7v6\u81ea\u7136\u8fde\u4e0d\u4e0a<\/p>\n<p>&nbsp;<\/p>\n<p>\u90a3\u4e48\u6211\u4eec\u5982\u679c\u6307\u5b9a nc \u53ea\u76d1\u542c IPv6\uff0c\u90a3\u4e48\u662f\u4e0d\u662f <code>nc -v 127.0.0.1 12345<\/code> \u5c31\u4e0d\u884c\u4e86\u5462\uff1f<\/p>\n<pre class=\"prettyprint linenums\">nc -klv :: 12345\r\n<\/pre>\n<p>\u518d\u5f00\u4e00\u4e2a\u65b0\u7a97\u53e3<\/p>\n<pre class=\"prettyprint linenums\">~ \u27a4 nc -v 127.0.0.1 12345\r\nConnection to 127.0.0.1 port 12345 [tcp\/italk] succeeded!\r\n^C\r\n\r\n~ \u27a4 nc -v ::1 12345\r\nConnection to ::1 port 12345 [tcp\/italk] succeeded!\r\n<\/pre>\n<p>\u554a\uff0c\u7adf\u7136\u90fd\u53ef\u4ee5\uff0c\u610f\u5473\u7740\u65e0\u8bba\u662fIPv4\u8fd8\u662fIPv6\u90fd\u53ef\u4ee5\u8fde\u63a5\uff01<\/p>\n<div id=\"sc_blue\">nc -klv localhost 12345 \u5462\uff1f\u8fd9\u53d6\u51b3\u4e8e localhost \u7684\u89e3\u6790\u7ed3\u679c<\/div>\n<p>\u8fd9\u662f\u4e3a\u4ec0\u4e48\u5462\uff1f<\/p>\n<h2>net.ipv6.bindv6only<\/h2>\n<p>\u8fd9\u662f Linux \u5185\u6838\u7684\u4e00\u4e2a\u53c2\u6570\uff0c\u7528\u4e8e\u5b9a\u4e49\u76d1\u542cIPv6\u5730\u5740\u65f6\u7684\u884c\u4e3a\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u8fd9\u4e2a\u503c\u662f0 \u7981\u7528\uff0c\u4e5f\u5c31\u610f\u5473\u7740\uff0c\u5982\u679c\u4f60\u76d1\u542c\u4e86<code>::<\/code> \u90a3\u4e48\u4e5f\u76f8\u5f53\u4e8e\u76d1\u542c\u4e86 <code>0.0.0.0<\/code><\/p>\n<p>\u4ece <code>netstat<\/code> \u4e2d\u6211\u4eec\u53ef\u4ee5\u770b\u51fa<\/p>\n<h3>\u5982\u679c\u662f :: \u7684\u8bdd<\/h3>\n<pre class=\"prettyprint linenums\">tcp6 0 0 :::12345 :::* LISTEN 1925847\/nc\r\n<\/pre>\n<h3>\u5982\u679c\u662f 0.0.0.0\u7684\u8bdd<\/h3>\n<pre class=\"prettyprint linenums\">tcp 0 0 0.0.0.0:12345 0.0.0.0:* LISTEN 1926110\/nc\r\n<\/pre>\n<h3>\u5982\u679c\u6211\u4eec\u901a\u8fc7 <code>sysctl<\/code> \u542f\u7528\u8fd9\u4e2a\u53c2\u6570<\/h3>\n<pre class=\"prettyprint linenums\">sysctl net.ipv6.bindv6only=1\r\n<\/pre>\n<p>\u7136\u540e\u518d\u6b21\u76d1\u542c <code>nc -klv :: 12345<\/code><\/p>\n<p>\u518d\u6b21\u901a\u8fc7 nc\u53bb\u8fde\u63a5 <code>127.0.0.1<\/code><\/p>\n<pre class=\"prettyprint linenums\">nc -v 127.0.0.1 12345\r\nnc: connect to 127.0.0.1 port 12345 (tcp) failed: Connection refused\r\n<\/pre>\n<p>\u5c31\u4f1a\u53d1\u73b0\u8fde\u4e0d\u4e0a\u4e86\uff0c\u56e0\u4e3a\u6b64\u65f6\u53ea\u76d1\u542c IPv6\u7684\u5730\u5740\uff0c\u5bf9\u4e8eIPv4\u7684\u5bf9\u5e94\u7aef\u53e3\u5e76\u6ca1\u6709\u7a0b\u5e8f\u5728\u76d1\u542c\u3002<\/p>\n<p>\u5728\u7edd\u5927\u591a\u6570 Linux \u53d1\u884c\u7248\u4e2d\uff0c <code>net.ipv6.bindv6only<\/code> \u7684\u9ed8\u8ba4\u503c\u90fd\u662f0\uff0c\u4e5f\u5c31\u610f\u5473\u7740\u76d1\u542c\u5728 <code>::<\/code> \u4e5f\u540c\u6837\u610f\u5473\u7740\u76d1\u542c\u5728 <code>0.0.0.0<\/code> \uff1b\u6362\u53e5\u8bdd\u8bf4\uff0c\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u770b\u5230 <code>tcp6 :::port<\/code> \u4e5f\u5c31\u610f\u5473\u7740\u901a\u8fc7 IPv4 \u4e5f\u53ef\u4ee5\u8fde\u63a5\u4e0a\u3002<\/p>\n<p>macOS\u4e5f\u540c\u6837\u6709\u8fd9\u6837\u7684\u884c\u4e3a\uff0c\u81f3\u4e8eWindows\u561b\u2026\u2026\u53ef\u80fd\u4e5f\u662f\uff0c\u6211\u6ca1\u6709Windows\u7684\u673a\u5668\u6765\u505a\u6d4b\u8bd5\u3002<\/p>\n<h2>\u7279\u6b8a\u60c5\u51b5<\/h2>\n<p>\u5bf9\u4e8e\u5927\u591a\u6570\u5e94\u7528\u7a0b\u5e8f\uff0c<code>localhost<\/code> \u65e0\u975e\u5c31\u662f\u5bf9\u5e94 <code>::1<\/code> \u548c\u6216 <code>127.0.0.1<\/code> .\u4f46\u662fMySQL\u662f\u4e2a\u4f8b\u5916\uff0c\u5f53\u4f60\u7528 <code>localhost<\/code> \u65f6\uff0cMySQL\u4f1a\u901a\u8fc7 UNIX\u5957\u63a5\u5b57\uff08<code>\/var\/run\/mysqld\/mysqld.sock<\/code>\uff09 \u53bb\u8fde\u63a5<\/p>\n<h2>\u5c0f\u7ed3<\/h2>\n<ul>\n<li>\u76d1\u542c <code>127.0.0.1<\/code> \u610f\u5473\u7740\u53ea\u6709\u4ece 127\u6765\u7684\u8bf7\u6c42\u53ef\u4ee5\u63a5\u53d7\uff0c<code>::1<\/code> \u540c\u7406<\/li>\n<li>\u5728\u5927\u591a\u6570\u60c5\u51b5\u4e0b <code>net.ipv6.bindv6only=0<\/code>\u4e3a\u9ed8\u8ba4\u503c\u3002 \u76d1\u542c <code>::<\/code> \u540c\u65f6\u610f\u5473\u7740\u76d1\u542c<code>0.0.0.0<\/code><\/li>\n<li>\u5728\u672a\u660e\u786e\u7981\u7528 IPv6\u7684\u60c5\u51b5\u4e0b\uff0c\u5373\u4fbf\u4f60\u6ca1\u6709IPv6 \u5730\u5740\uff0c\u90a3\u4e48\u5927\u591a\u6570\u60c5\u51b5\u4e0b <code>localhost<\/code> \u4e5f\u4f1a\u88ab hosts\u5b9a\u4e49\u5230 <code>::1<\/code> \u548c <code>127.0.0.1<\/code>\uff1b\u5e76\u4e14\u4f60\u4e5f\u80fd\u76d1\u542c\u5728 <code>::<\/code><\/li>\n<li>MySQL\u7684localhost\u662f\u5957\u63a5\u5b57<\/li>\n<li>\u5982\u679c\u540c\u65f6\u89e3\u6790\u5230\u4e86IPv6\u548cIPv4\uff0c\u90a3\u4e48\u5e94\u8be5\u4f18\u5148 IPv6\uff1b\u5982\u679cIPv6\u8fde\u63a5\u5931\u8d25\uff0c\u90a3\u4e48\u7406\u60f3\u60c5\u51b5\u662f\u5e94\u8be5\u56de\u843d\u5230 IPv4\uff0c\u6240\u8c13\u201c<a href=\"https:\/\/zh.wikipedia.org\/zh-cn\/Happy_Eyeballs\">\u5feb\u4e50\u773c\u7403\uff08Happy eyeballs\uff09<\/a>\u201d\u7b97\u6cd5<\/li>\n<\/ul>\n<hr \/>\n<h2>Node.js \uff1f\uff1f\uff1f<\/h2>\n<p>\u4f60\u4ee5\u4e3a\u4e8b\u60c5\u5230\u8fd9\u91cc\u5c31\u7ed3\u675f\u4e86\u5417\uff1f\u5e76\u6ca1\u6709\u3002<\/p>\n<p>\u660e\u660e\u5e94\u8be5\u652f\u6301\u5feb\u4e50\u773c\u7403\u7b97\u6cd5\u7684\uff0c\u4f46\u662f\u540e\u7aef\u53ea\u76d1\u542c\u4e86 <code>0.0.0.0<\/code> \u4e3a\u4ec0\u4e48 redbird\u7684\u914d\u7f6e\u4e2d\u5199 <code>localhost<\/code>\u8fd8\u662f\u5931\u8d25\u4e86\u5462\uff1f\u5e76\u4e14\u5728\u4f7f\u7528 Node.js 16\u7684\u65f6\u5019\u6ca1\u95ee\u9898\uff0c18\u5c31\u6709\u95ee\u9898\u4e86\u3002<\/p>\n<h3>\u91cd\u65b0\u4f7f\u7528 nc \u76d1\u542c\u5230 <code>0.0.0.0 <\/code><\/h3>\n<pre class=\"prettyprint linenums\">nc -klv 0.0.0.0 12345\r\n<\/pre>\n<p>\u5e76\u4e14\u5df2\u7ecf\u786e\u8ba4\u53ea\u6709 IPv4\u53ef\u8fbe\uff0c\u5728 <code>nc -v localhost 12345<\/code> \u65f6\u4f1a\u5148\u5931\u8d25\u518d\u6210\u529f<\/p>\n<h3>\u4f7f\u7528\u5982\u4e0b\u7b80\u5355\u7684 Node.js \u4ee3\u7801\u6765\u6d4b\u8bd5<\/h3>\n<pre class=\"prettyprint linenums\">const net = require(&quot;net&quot;);\r\nconst client = new net.Socket();\r\nclient.connect(12345, &quot;localhost&quot;, function () {\r\n    client.write(`node js ${process.version}\\n`);\r\n    console.log(&quot;Connected&quot;);\r\n    process.exit(0);\r\n});\r\n<\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/7bc5d24.webp.ee\/wp-content\/uploads\/2023\/11\/2023112603044820.jpeg\" alt=\"Node.js 18\u5347\u7ea7\uff1a\u53cc\u6808\u534f\u8bae\u8e29\u5751\" title=\"Node.js 18\u5347\u7ea7\uff1a\u53cc\u6808\u534f\u8bae\u8e29\u5751\" alt=\"\u56fe\u5f62\u7528\u6237\u754c\u9762, \u6587\u672c, \u5e94\u7528\u7a0b\u5e8f, \u7535\u5b50\u90ae\u4ef6 \u63cf\u8ff0\u5df2\u81ea\u52a8\u751f\u6210\" \/><\/p>\n<p>\u8fd9\u662f\u4ec0\u4e48\u60c5\u51b5\uff1f<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/7bc5d24.webp.ee\/wp-content\/uploads\/2023\/11\/2023112603044973.png\" alt=\"Node.js 18\u5347\u7ea7\uff1a\u53cc\u6808\u534f\u8bae\u8e29\u5751\" title=\"Node.js 18\u5347\u7ea7\uff1a\u53cc\u6808\u534f\u8bae\u8e29\u5751\" alt=\"\u8c93\u8c93\u87f2\u5496\u6ce2-\u958b\u5fc3\u96a8\u4f60(\u4e0a) - Download Stickers from Sigstick\" \/><\/p>\n<pre class=\"prettyprint linenums\">$ for i in {12..21}; do nvm use $i &amp;&amp; node test.js; done\r\nNow using node v12.22.12 (npm v6.14.16)\r\nConnected\r\nNow using node v13.14.0 (npm v6.14.4)\r\nConnected\r\nNow using node v14.21.3 (npm v6.14.18)\r\nConnected\r\nNow using node v15.14.0 (npm v7.7.6)\r\nConnected\r\nNow using node v16.20.2 (npm v8.19.4)\r\nConnected\r\nNow using node v17.9.1 (npm v8.11.0)\r\nnode:events:505\r\n      throw er; \/\/ Unhandled &#039;error&#039; event\r\n      ^\r\n\r\nError: connect ECONNREFUSED ::1:12345\r\n    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1195:16)\r\nEmitted &#039;error&#039; event on Socket instance at:\r\n    at emitErrorNT (node:internal\/streams\/destroy:164:8)\r\n    at emitErrorCloseNT (node:internal\/streams\/destroy:129:3)\r\n    at processTicksAndRejections (node:internal\/process\/task_queues:83:21) {\r\n  errno: -61,\r\n  code: &#039;ECONNREFUSED&#039;,\r\n  syscall: &#039;connect&#039;,\r\n  address: &#039;::1&#039;,\r\n  port: 12345\r\n}\r\n\r\nNode.js v17.9.1\r\nNow using node v18.18.2 (npm v9.8.1)\r\nnode:events:495\r\n      throw er; \/\/ Unhandled &#039;error&#039; event\r\n      ^\r\n\r\nError: connect ECONNREFUSED ::1:12345\r\n    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1555:16)\r\nEmitted &#039;error&#039; event on Socket instance at:\r\n    at emitErrorNT (node:internal\/streams\/destroy:151:8)\r\n    at emitErrorCloseNT (node:internal\/streams\/destroy:116:3)\r\n    at process.processTicksAndRejections (node:internal\/process\/task_queues:82:21) {\r\n  errno: -61,\r\n  code: &#039;ECONNREFUSED&#039;,\r\n  syscall: &#039;connect&#039;,\r\n  address: &#039;::1&#039;,\r\n  port: 12345\r\n}\r\n\r\nNode.js v18.18.2\r\nNow using node v19.9.0 (npm v9.6.3)\r\nnode:events:491\r\n      throw er; \/\/ Unhandled &#039;error&#039; event\r\n      ^\r\n\r\nError: connect ECONNREFUSED ::1:12345\r\n    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1532:16)\r\nEmitted &#039;error&#039; event on Socket instance at:\r\n    at emitErrorNT (node:internal\/streams\/destroy:151:8)\r\n    at emitErrorCloseNT (node:internal\/streams\/destroy:116:3)\r\n    at process.processTicksAndRejections (node:internal\/process\/task_queues:82:21) {\r\n  errno: -61,\r\n  code: &#039;ECONNREFUSED&#039;,\r\n  syscall: &#039;connect&#039;,\r\n  address: &#039;::1&#039;,\r\n  port: 12345\r\n}\r\n\r\nNode.js v19.9.0\r\nNow using node v20.10.0 (npm v10.2.3)\r\nConnected\r\nNow using node v21.2.0 (npm v10.2.3)\r\nConnected\r\n<\/pre>\n<p>\u54b3\uff0c\u4e0d\u8fc7\u662fNode.js\u81ea\u4ece17\u5c31\u5f04\u574f\u4e86\u5feb\u4e50\u773c\u7403\u7b97\u6cd5\uff0c18\u300119\u4e5f\u662f\u574f\u7740\u7684\uff0c\u76f4\u523020\u624d\u4fee\u597d\u300216\u4e4b\u524d\u7684\u7248\u672c\u5168\u662f\u597d\u7684\u3002<\/p>\n<p>18\u662fLTS\u554a\uff0c\u54ce\uff0c\u8fd9\u96be\u514d\u6709\u70b9\u592a<a href=\"https:\/\/twitter.com\/BennyThinks\/status\/1728062988765335859\">\u8349\u53f0\u73ed\u5b50<\/a>\u4e86\u5427\u3002<\/p>\n<h2>\u53c2\u8003\u8d44\u6599<\/h2>\n<p><a href=\"https:\/\/github.com\/nodejs\/node\/issues\/41625\">https:\/\/github.com\/nodejs\/node\/issues\/41625<\/a><br \/>\n<a href=\"https:\/\/github.com\/nodejs\/node\/issues\/40702\">https:\/\/github.com\/nodejs\/node\/issues\/40702<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5f88\u4e45\u4e4b\u524d\u6211\u5c31\u53d1\u73b0\u4e86\u4e00\u4e2a\u73b0\u8c61\uff0c\u6709\u4e9b\u65f6\u5019\u6211\u5728\u4f7f\u7528 nc\u53bb\u63a2\u6d4b\u672c\u5730\u7684\u67d0\u4e9b\u670d\u52a1\u662f\u5426\u5f00\u542f\u65f6\uff0c\u4f1a\u6709\u4e24\u4e2a\u8f93\u51fa\uff0c\u7b2c\u4e00\u6b21\u62d2\u7edd\u7b2c\u4e8c [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[38],"tags":[],"class_list":["post-5747","post","type-post","status-publish","format-standard","hentry","category-program"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/dmesg.app\/wp-json\/wp\/v2\/posts\/5747","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dmesg.app\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dmesg.app\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dmesg.app\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dmesg.app\/wp-json\/wp\/v2\/comments?post=5747"}],"version-history":[{"count":14,"href":"https:\/\/dmesg.app\/wp-json\/wp\/v2\/posts\/5747\/revisions"}],"predecessor-version":[{"id":5764,"href":"https:\/\/dmesg.app\/wp-json\/wp\/v2\/posts\/5747\/revisions\/5764"}],"wp:attachment":[{"href":"https:\/\/dmesg.app\/wp-json\/wp\/v2\/media?parent=5747"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dmesg.app\/wp-json\/wp\/v2\/categories?post=5747"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dmesg.app\/wp-json\/wp\/v2\/tags?post=5747"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}