{"id":2832,"date":"2023-06-07T14:11:57","date_gmt":"2023-06-07T05:11:57","guid":{"rendered":"https:\/\/attacktube.com\/?p=2832"},"modified":"2023-07-08T07:12:49","modified_gmt":"2023-07-07T22:12:49","slug":"%e3%80%90node-js%e3%80%91http%e3%82%b5%e3%83%bc%e3%83%90%e3%83%bc%e3%82%92%e7%ab%8b%e3%81%a1%e4%b8%8a%e3%81%92%e3%82%8b-%e3%81%9d%e3%81%ae2","status":"publish","type":"post","link":"https:\/\/attacktube.com\/?p=2832","title":{"rendered":"\u3010Node.js\u3011http\u30b5\u30fc\u30d0\u30fc\u3092\u7acb\u3061\u4e0a\u3052\u308b \u305d\u306e2(TCP\u63a5\u7d9a\u306e\u78ba\u7acb\u3068\u5207\u65ad\u306e\u691c\u51fa)"},"content":{"rendered":"\n<p>Node.js\u3067http\u30b5\u30fc\u30d0\u30fc\u3092\u7acb\u3061\u4e0a\u3052\u308b\u3002<br>TCP\u63a5\u7d9a\u304c\u78ba\u7acb\u3055\u308c\u305f\u6642\u3068TCP\u63a5\u7d9a\u9589\u3058\u305f\u6642\u306b\u30b3\u30de\u30f3\u30c9\u30d7\u30ed\u30f3\u30d7\u30c8\u306b\u30ed\u30b0\u3092\u51fa\u3059\u3088\u3046\u306b\u3059\u308b\u3002<br>\u305d\u308c\u3068\u3001keep-alive\u6a5f\u80fd\u3092\u7121\u52b9\u306b\u3059\u308b\u306b\u306fserver.keepAliveTimeout = 0;\u3068\u3057\u305f\u3089\u3044\u3044\u3089\u3057\u3044\u3002<br>\u3057\u304b\u3057\u3001server.keepAliveTimeout = 0;\u3068\u3057\u3066\u3082closed\u304c2\u56de\u5b9f\u884c\u3055\u308c\u3066\u3044\u308b\u304b\u3089\u7121\u52b9\u306b\u306a\u3089\u306a\u3044\u307f\u305f\u3044\u3002<br><br>\u74b0\u5883<br>Windows10(64bit)<br>nvm(Node Version Manager)\u3092\u4f7f\u7528\u3059\u308b\u3002<br>nvm\u306fnode\u3068npm\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u306e\u5207\u308a\u66ff\u3048\u304c\u3067\u304d\u308b\u3002<br>node.js\u306f\u30a2\u30c3\u30d7\u30c7\u30fc\u30c8\u304c\u983b\u7e41\u306b\u884c\u308f\u308c\u308b\u305f\u3081\u3001\u30d0\u30fc\u30b8\u30e7\u30f3\u7ba1\u7406\u30c4\u30fc\u30eb\u3092\u4f7f\u3046\u3068\u90fd\u5408\u304c\u826f\u3044\u3053\u3068\u304c\u591a\u3044\u3002<br>\u300c\u7279\u5b9a\u306e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306b\u5fc5\u8981\u306aNode.js\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u3092\u7c21\u5358\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u4f7f\u7528\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3002\u300d\u3084\u300c\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u6bce\u306bNode.js\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u306e\u5207\u308a\u66ff\u3048\u304c\u7c21\u5358\u306b\u306a\u308b\u3002\u300d\u7b49\u306e\u30e1\u30ea\u30c3\u30c8\u304c\u3042\u308b\u3002<br>nvm 1.1.10<br>node v18.15.0<br>npm 9.5.0<\/p>\n\n\n\n<!--more-->\n\n\n\n<br>\n<script async=\"\" src=\"https:\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js?client=ca-pub-3461056110605997\" crossorigin=\"anonymous\"><\/script>\n<ins class=\"adsbygoogle\" style=\"display:block; text-align:center;\" data-ad-layout=\"in-article\" data-ad-format=\"fluid\" data-ad-client=\"ca-pub-3461056110605997\" data-ad-slot=\"3137443461\"><\/ins>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script>\n<br>\n\n\n\n<p>http\u30b5\u30fc\u30d0\u30fc\u3092\u7acb\u3061\u4e0a\u3052\u308b\u30b3\u30fc\u30c9\u300chttp.js\u300d\u3092\u6b21\u306b\u793a\u3059\u3002<br>\u73fe\u5730\u6642\u9593\u3092\u53d6\u5f97\u3059\u308b\u305f\u3081\u306b\u81ea\u4f5c\u30e2\u30b8\u30e5\u30fc\u30ebLocalTime.js\u3092\u4f7f\u7528\u3057\u3066\u3044\u308b\u3002<\/p>\n\n\n\n<pre><code>\n(function() {\n\n    \/\/ \u81ea\u4f5c\u30e2\u30b8\u30e5\u30fc\u30ebLocalTime.js\u3092require\u3092\u4f7f\u3063\u3066\u30a4\u30f3\u30dd\u30fc\u30c8\u3057\u3066\u3001\u5b9a\u6570localTime\u306b\u683c\u7d0d\u3059\u308b\u3002\n    const localTime = require(&quot;.\/LocalTime.js&quot;);\n\n    \/\/ LocalTime\u306e\u8a00\u8a9e\u3092\u65e5\u672c\u8a9e\u306b\u8a2d\u5b9a\n    localTime.SetLang(&quot;JP&quot;);\n    \/\/ LocalTime\u306e\u30bf\u30a4\u30e0\u30be\u30fc\u30f3\u3092\u6771\u4eac(TYO)\u306b\u8a2d\u5b9a\n    localTime.SetTimeZone(&quot;TYO&quot;);\n\n    \/\/ Node.js\u306ehttp\u30e2\u30b8\u30e5\u30fc\u30eb\u3092require\u3092\u4f7f\u3063\u3066\u30a4\u30f3\u30dd\u30fc\u30c8\u3057\u3066\u3001\u5b9a\u6570http\u306b\u683c\u7d0d\u3059\u308b\u3002\n    const http = require(&quot;http&quot;);\n\n    const port = 3000; \/\/port\u756a\u53f7\n    \/\/const hostname = &quot;localhost&quot;; \/\/ \u30db\u30b9\u30c8\u540d\u307e\u305f\u306f\u30c9\u30e1\u30a4\u30f3\u540d\n    const hostname = &quot;192.168.2.100&quot;; \/\/ \u30db\u30b9\u30c8\u540d\u307e\u305f\u306f\u30c9\u30e1\u30a4\u30f3\u540d\n\n\n    \/\/ http\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u304b\u3089createServer\u30e1\u30bd\u30c3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3002\n    \/\/ createServer\u30e1\u30bd\u30c3\u30c9\u306f\u3001\u5f15\u6570\u3068\u3057\u3066\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u51e6\u7406\u3059\u308b\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u95a2\u6570\u3092\u53d7\u3051\u53d6\u308b\u3002\n    \/\/ \u3053\u306e\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u95a2\u6570\u306f\u3001\u30ea\u30af\u30a8\u30b9\u30c8\u304c\u767a\u751f\u3057\u305f\u969b\u306b\u5b9f\u884c\u3055\u308c\u3001\u30ea\u30af\u30a8\u30b9\u30c8\u30aa\u30d6\u30b8\u30a7\u30af\u30c8(req)\u3068\u30ec\u30b9\u30dd\u30f3\u30b9\u30aa\u30d6\u30b8\u30a7\u30af\u30c8(res)\u3092\u53d7\u3051\u53d6\u308b\n    \/\/ \u3064\u307e\u308a\u3001\u3053\u306e\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u95a2\u6570\u306f\u3001http:\/\/localhost:3000\u306b\u30a2\u30af\u30bb\u30b9\u3057\u305f\u3068\u304d\u306b\u5b9f\u884c\u3055\u308c\u308b\u3002\n    \/\/ \u3053\u306e\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u95a2\u6570\u5185\u3067\u3001\u9069\u5207\u306a\u30ec\u30b9\u30dd\u30f3\u30b9(res)\u3092\u751f\u6210\u3057\u3066\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u306b\u9001\u4fe1\u3059\u308b\u51e6\u7406\u3092\u5b9f\u88c5\u3059\u308b\u3002\n    \/\/ \u30ea\u30af\u30a8\u30b9\u30c8\u30aa\u30d6\u30b8\u30a7\u30af\u30c8(req)\u306f\u3001http.IncomingMessage\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3067\u3042\u308b\u3002\n    \/\/ \u30ec\u30b9\u30dd\u30f3\u30b9\u30aa\u30d6\u30b8\u30a7\u30af\u30c8(res)\u306f\u3001http.ServerResponse\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3067\u3042\u308b\u3002\n    \/\/ \u30ec\u30b9\u30dd\u30f3\u30b9\u30aa\u30d6\u30b8\u30a7\u30af\u30c8(res)\u306f\u3001Writable\u30b9\u30c8\u30ea\u30fc\u30e0\u3068\u3057\u3066\u6a5f\u80fd\u3059\u308b\u3002\n    \/\/ \u30ec\u30b9\u30dd\u30f3\u30b9\u30aa\u30d6\u30b8\u30a7\u30af\u30c8(res)\u306f\u3001\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u306b\u5bfe\u3057\u3066\u30c7\u30fc\u30bf\u3092\u9001\u4fe1\u3059\u308b\u305f\u3081\u306e\u30b9\u30c8\u30ea\u30fc\u30e0\u3068\u3057\u3066\u6271\u308f\u308c\u308b\u3002\n\n    \/\/ req\u306fhttp.IncomingMessage\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3067\u3042\u308a\u3001HTTP\u30ea\u30af\u30a8\u30b9\u30c8\u306e\u30c7\u30fc\u30bf\u3092\u8aad\u307f\u53d6\u308b\u305f\u3081\u306e\n    \/\/ Readable\u30b9\u30c8\u30ea\u30fc\u30e0\u3067\u3059\u3002\u30ea\u30af\u30a8\u30b9\u30c8\u30d8\u30c3\u30c0\u30fc\u3084\u30dc\u30c7\u30a3\u306a\u3069\u306e\u30c7\u30fc\u30bf\u3092\u8aad\u307f\u53d6\u308b\u305f\u3081\u306b\u4f7f\u7528\u3057\u307e\u3059\u3002\n\n    \/\/ res\u306fhttp.ServerResponse\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3067\u3042\u308a\u3001HTTP\u30ec\u30b9\u30dd\u30f3\u30b9\u3092\u751f\u6210\u304a\u3088\u3073\u9001\u4fe1\u3059\u308b\u305f\u3081\u306e\n    \/\/ Writable\u30b9\u30c8\u30ea\u30fc\u30e0\u3067\u3059\u3002res\u306b\u5bfe\u3057\u3066\u66f8\u304d\u8fbc\u307e\u308c\u305f\u30c7\u30fc\u30bf\u306f\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u306b\u9001\u4fe1\u3055\u308c\u307e\u3059\u3002\n    \/\/ write\u30e1\u30bd\u30c3\u30c9\u3084end\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u7528\u3057\u3066\u30ec\u30b9\u30dd\u30f3\u30b9\u30dc\u30c7\u30a3\u3092\u66f8\u304d\u8fbc\u3080\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\n    \/\/ \u30ec\u30b9\u30dd\u30f3\u30b9\u30aa\u30d6\u30b8\u30a7\u30af\u30c8(res)\u306e\u30dc\u30c7\u30a3\u306b\u66f8\u304d\u8fbc\u3080\u306b\u306fwrite\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u3046\u3002\n    \/\/ \u30ec\u30b9\u30dd\u30f3\u30b9\u30aa\u30d6\u30b8\u30a7\u30af\u30c8(res)\u306e\u9001\u4fe1\u3092\u5b8c\u4e86\u3059\u308b\u305f\u3081\u306b\u306fend\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u3046\u3002\n\n    const server = http.createServer((req, res) =&gt; {\n\n        \/\/ \u3053\u306e\u90e8\u5206\u306e\u30b3\u30fc\u30c9 req.connection.remoteAddress \u306f\u3001HTTP\u30ea\u30af\u30a8\u30b9\u30c8\u306e\u63a5\u7d9a\u60c5\u5831\u306b\u542b\u307e\u308c\u308b\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u306eIP\u30a2\u30c9\u30ec\u30b9\u3092\u53d6\u5f97\u3059\u308b\u305f\u3081\u306e\u3082\u306e\u3067\u3059\u3002\n        \/\/ req\u306f\u30ea\u30af\u30a8\u30b9\u30c8\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3067\u3042\u308a\u3001connection\u30d7\u30ed\u30d1\u30c6\u30a3\u306f\u63a5\u7d9a\u60c5\u5831\u3092\u8868\u3059\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u53d6\u5f97\u3059\u308b\u3002\u305d\u3057\u3066\u3001remoteAddress\u30d7\u30ed\u30d1\u30c6\u30a3\u306f\n        \/\/ \u305d\u306e\u63a5\u7d9a\u5143\u306eIP\u30a2\u30c9\u30ec\u30b9\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002\n\n        \/\/ \u306a\u304a\u3001remoteAddress\u306f\u4e00\u822c\u7684\u306b\u306f\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u306e\u5b9f\u969b\u306eIP\u30a2\u30c9\u30ec\u30b9\u3092\u8868\u3059\u3002\n        \/\/ \u3057\u304b\u3057\u3001\u30d7\u30ed\u30ad\u30b7\u30b5\u30fc\u30d0\u3084\u30ed\u30fc\u30c9\u30d0\u30e9\u30f3\u30b5\u3092\u7d4c\u7531\u3057\u3066\u3044\u308b\u5834\u5408\u306b\u306f\u3001\u305d\u306e\u30b5\u30fc\u30d0\u306eIP\u30a2\u30c9\u30ec\u30b9\u304c\u53d6\u5f97\u3055\u308c\u308b\u3053\u3068\u304c\u3042\u308a\u3048\u308b\u3002\n        \/\/ \u3053\u306e\u70b9\u306f\u6ce8\u610f\u3059\u308b\u3053\u3068\u3002\n\n        \/\/\u53d6\u5f97\u3057\u305f\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u306eIP\u30a2\u30c9\u30ec\u30b9\u3092clientIP\u306b\u683c\u7d0d\u3059\u308b\u3002\n        const clientIP = req.connection.remoteAddress;\n\n        console.log(\n            `Executed. \\n` +\n            `${localTime.GetLocalTimeString()} \\n` +\n            `\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u306eIP\u30a2\u30c9\u30ec\u30b9:${clientIP}\\n` +\n            `${req.method} \\n` +\n            `${req.url} \\n` +\n            `${req.headers[&quot;user-agent&quot;]}`\n        );\n\n        const url = `http:\/\/${req.headers.host}`;\n\n        \/\/ URL\u89e3\u6790\n        \/\/ req.url\u306f\u76f8\u5bfeURL\u304c\u5165\u308b\u3002\n        \/\/ url\u306f\u30d9\u30fc\u30b9url(\u76f8\u5bfeURL\u3092\u89e3\u6c7a\u3059\u308b\u305f\u3081\u306e\u57fa\u6e96\u3068\u306a\u308bURL)\u304c\u5165\u308b\u3002\n        const myURL = new URL(req.url, url);\n        const whitespace = 2;\n        const result = [];\n        const names = [];\n\n        let stringLengthMax = 0;\n        let buf = &quot; &quot;;\n        let blanks = &quot;&quot;;\n\n        console.log(&quot;&quot;);\n\n        result.push(myURL.href);\n        result.push(myURL.origin);\n        result.push(myURL.protocol);\n        result.push(myURL.username);\n        result.push(myURL.password);\n        result.push(myURL.host);\n        result.push(myURL.port);\n        result.push(myURL.hostname);\n        result.push(myURL.pathname);\n        result.push(myURL.hash);\n        result.push(myURL.search);\n\n        names.push(&quot;href&quot;);\n        names.push(&quot;origin&quot;);\n        names.push(&quot;protocol&quot;);\n        names.push(&quot;username&quot;);\n        names.push(&quot;password&quot;);\n        names.push(&quot;host&quot;);\n        names.push(&quot;port&quot;);\n        names.push(&quot;hostname&quot;);\n        names.push(&quot;pathname&quot;);\n        names.push(&quot;hash&quot;);\n        names.push(&quot;search&quot;);\n\n        \/\/ names\u914d\u5217\u306e\u4e2d\u306e\u6587\u5b57\u5217\u3067\u6700\u5927\u9577\u3092stringLengthMax\u306b\u683c\u7d0d\u3059\u308b\u3002\n        names.forEach(t =&gt; {\n            if (t.length &gt; stringLengthMax) stringLengthMax = t.length;\n        });\n\n        \/\/ buf\u306b\u683c\u7d0d\u3057\u305f\u7a7a\u306e\u6587\u5b57\u5217\u3092\u300cstringLengthMax + whitespace\u300d\u56de\u6570\u5206\u306e\u30b3\u30d4\u30fc\u3092\u542b\u3080\u65b0\u3057\u3044\u6587\u5b57\u5217blanks\u3092\u4f5c\u308b\u3002\u3000\n        blanks = buf.repeat(stringLengthMax + whitespace);\n\n        \/\/ URL\u306e\u89e3\u6790\u7d50\u679c\u3092\u51fa\u3059\u3002\n        names.forEach((t, u) =&gt; (console.log(t + &quot;:&quot; + blanks.slice(t.length) + result[u])));\n\n        console.log(&quot;&quot;);\n        console.log(&quot;req.headers = &quot;);\n        console.log(req.headers);\n        console.log(&quot;&quot;);\n\n        let str = [];\n\n        str.push(&quot;method:&quot;);\n        str.push(req.method);\n        str.push(&quot;\\n&quot;);\n        str.push(&quot;req.url:&quot;);\n        str.push(req.url);\n        str.push(&quot;\\n&quot;);\n\n        if (myURL.pathname === &quot;\/&quot;) {\n\n            \/\/ \u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u30eb\u30fc\u30c8\uff08\/\uff09\u304c\u30ea\u30af\u30a8\u30b9\u30c8\u3055\u305f\u5834\u5408\n            res.writeHead(200, {\n                &quot;Content-Type&quot;: &quot;text\/plain;charset=utf-8&quot;\n            });\n\n            if (req.method === &quot;POST&quot;) {\n\n                let i = 0\n\n                \/\/ data\u53d7\u4fe1\u30a4\u30d9\u30f3\u30c8\u306e\u767a\u751f\u6642\u306b\u65ad\u7247\u30c7\u30fc\u30bf(chunk)\u3092\u53d6\u5f97\u3059\u308b\u3002\n                req.on(&quot;data&quot;, chunk =&gt; {\n                    console.log(localTime.GetLocalTimeString() + &quot; i = &quot; + i + &quot;, chunk = &quot; + chunk + &quot;&quot;);\n                    i += 1;\n                    str.push(chunk);\n                });\n\n                \/\/ \u53d7\u4fe1\u5b8c\u4e86(end)\u30a4\u30d9\u30f3\u30c8\u767a\u751f\u6642\n                \/\/\u300cend\u300d\u30a4\u30d9\u30f3\u30c8\u306f\u3001\u30ec\u30b9\u30dd\u30f3\u30b9\u306e\u30c7\u30fc\u30bf\u306e\u8aad\u307f\u53d6\u308a\u304c\u5b8c\u4e86\u3057\u305f\u5834\u5408\u306b\u767a\u751f\u3059\u308b\u3002\n                req.on(&quot;end&quot;, function() {\n                    str.push(&quot;\\n&quot;);\n                    \/\/\u30ec\u30b9\u30dd\u30f3\u30b9\u30c7\u30fc\u30bf\u3092chunk\u5206\u5272\u3059\u308b\u3002\n                    res.write(str.join(&quot;&quot;));\n                    res.end(&quot;Hello World! &quot; + req.method + &quot;\\n&quot;);\n                });\n\n            } else if (req.method === &quot;GET&quot;) {\n\n                \/\/ URLSearchParams\u306b\u542b\u307e\u308c\u308b\u5024\u306fforEach()\u30e1\u30bd\u30c3\u30c9\u3067\u53d6\u308a\u51fa\u3057\u53ef\u80fd\u3067\u3042\u308b\u3002\n                myURL.searchParams.forEach(function(value, key) {\n                    str.push(key + &quot; = &quot; + value + &quot;\\n&quot;);\n                    console.log(localTime.GetLocalTimeString() + &quot;, &quot; + key + &quot; = &quot; + value);\n                });\n\n                \/\/ \u30ec\u30b9\u30dd\u30f3\u30b9\u30c7\u30fc\u30bf\u3092chunk\u5206\u5272\u3059\u308b\u3002\n                res.write(str.join(&quot;&quot;));\n                res.end(&quot;Hello World! &quot; + req.method + &quot;\\n&quot;);\n\n            } else {\n\n                let i = 0\n\n                \/\/ data\u53d7\u4fe1\u30a4\u30d9\u30f3\u30c8\u306e\u767a\u751f\u6642\u306b\u65ad\u7247\u30c7\u30fc\u30bf(chunk)\u3092\u53d6\u5f97\u3059\u308b\u3002\n                req.on(&quot;data&quot;, chunk =&gt; {\n                    console.log(localTime.GetLocalTimeString() + &quot; i = &quot; + i + &quot;, chunk = &quot; + chunk + &quot;&quot;);\n                    i += 1;\n                    str.push(chunk);\n                });\n\n                \/\/ \u53d7\u4fe1\u5b8c\u4e86(end)\u30a4\u30d9\u30f3\u30c8\u767a\u751f\u6642\n                \/\/ \u300cend\u300d\u30a4\u30d9\u30f3\u30c8\u306f\u3001\u30ec\u30b9\u30dd\u30f3\u30b9\u306e\u30c7\u30fc\u30bf\u306e\u8aad\u307f\u53d6\u308a\u304c\u5b8c\u4e86\u3057\u305f\u5834\u5408\u306b\u767a\u751f\u3059\u308b\u3002\n                req.on(&quot;end&quot;, function() {\n                    str.push(&quot;\\n&quot;);\n                    \/\/\u30ec\u30b9\u30dd\u30f3\u30b9\u30c7\u30fc\u30bf\u3092chunk\u5206\u5272\u3059\u308b\u3002\n                    res.write(str.join(&quot;&quot;));\n                    res.end(&quot;Hi! &quot; + req.method);\n                });\n\n            }\n\n        } else {\n\n            \/\/ \u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u30eb\u30fc\u30c8(\/)\u304c\u30ea\u30af\u30a8\u30b9\u30c8\u3055\u308c\u306a\u3044\u5834\u5408\u306f\u30e1\u30bd\u30c3\u30c9\u306b\u95a2\u4fc2\u306a\u304f\u3053\u3053\u3092\u901a\u308b\u3002\n            res.writeHead(404, {\n                &quot;Content-Type&quot;: &quot;text\/plain;charset=utf-8&quot;\n            });\n\n            \/\/ \u30ec\u30b9\u30dd\u30f3\u30b9\u30c7\u30fc\u30bf\u3092chunk\u5206\u5272\u3059\u308b\u3002\n            res.write(str.join(&quot;&quot;));\n            res.end(&quot;404 Not Found&quot;);\n\n        }\n\n    });\n\n    \/\/ Keep-Alive\u3092\u7121\u52b9\u306b\u3059\u308b\u3002\n    \/\/ \u3057\u304b\u3057\u3001\u30bf\u30a4\u30e0\u30a2\u30a6\u30c8\u306eclose\u3068\u30d6\u30e9\u30a6\u30b6\u306e\u5207\u65ad\u306eclose\u306e2\u3064\u304c\u5b9f\u884c\u3055\u308c\u308b\u3002\n    \/\/ \u52b9\u3044\u3066\u3044\u306a\u3044\u306a\u3002\n    \/\/ server.keepAliveTimeout = 0;\n\n    \/\/ connection\u30a4\u30d9\u30f3\u30c8\u304c\u767a\u751f\u3057\u305f\u969b\u306b\u5b9f\u884c\u3055\u308c\u308b\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u95a2\u6570\u3092\u8a2d\u5b9a\u3059\u308b\u3002\n    \/\/ \u3053\u306e\u30a4\u30d9\u30f3\u30c8\u306f\u3001\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u3068\u306eTCP\u63a5\u7d9a\u304c\u78ba\u7acb\u3055\u308c\u305f\u6642\u306b\u767a\u751f\u3059\u308b\u3002\n\n    server.on(&#039;connection&#039;, (socket) =&gt; {\n\n        \/\/ socket.remoteAddress\u306f\u3001\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u306eIP\u30a2\u30c9\u30ec\u30b9\u3092\u53d6\u5f97\u3059\u308b\u305f\u3081\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u3067\u3042\u308b\u3002\n        \/\/ socket\u306f\u3001TCP\u63a5\u7d9a\u306e\u305f\u3081\u306e\u30bd\u30b1\u30c3\u30c8\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u8868\u3057\u3066\u304a\u308a\u3001\u305d\u306eremoteAddress\u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u4f7f\u7528\u3059\u308b\u3053\u3068\u3067\u3001\n        \/\/ \u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u306eIP\u30a2\u30c9\u30ec\u30b9\u3092\u53d6\u5f97\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3002\n\n        const clientIP = socket.remoteAddress;\n\n        console.log(`${localTime.GetLocalTimeString()} TCP connection established. \u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u306eIP\u30a2\u30c9\u30ec\u30b9:${clientIP}`);\n\n        \/\/ \u30bf\u30a4\u30e0\u30a2\u30a6\u30c8\u306e\u8a2d\u5b9a\n        \/\/ 2\u79d2\u306e\u30bf\u30a4\u30e0\u30a2\u30a6\u30c8\u5024\u3092\u8a2d\u5b9a\n        socket.setTimeout(2000);\n\n        \/\/ \u30bf\u30a4\u30e0\u30a2\u30a6\u30c8\u306e\u5024\u3092\u53d6\u5f97\n        const timeout = socket.timeout;\n        console.log(&#039;\u30bf\u30a4\u30e0\u30a2\u30a6\u30c8:&#039; + timeout);\n\n        \/\/close\u30a4\u30d9\u30f3\u30c8\u306f\u3001\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u3068\u306eTCP\u63a5\u7d9a\u304c\u9589\u3058\u3089\u308c\u305f\u6642\u306b\u767a\u751f\u3059\u308b\u3002\n        socket.on(&#039;close&#039;, () =&gt; {\n            console.log(`${localTime.GetLocalTimeString()} TCP connection closed. \u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u306eIP\u30a2\u30c9\u30ec\u30b9:${clientIP}\\n`);\n        });\n\n    });\n\n    \/\/ server\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u304b\u3089listen\u30e1\u30bd\u30c3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3002\n    \/\/ http\u30b5\u30fc\u30d0\u30fc\u304c\u6307\u5b9a\u3055\u308c\u305f\u30dd\u30fc\u30c8(3000)\u3067\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u53d7\u3051\u4ed8\u3051\u308b\u3088\u3046\u306b\u306a\u308b\u3002\n    server.listen(port, hostname, () =&gt; {\n        console.log(localTime.GetLocalTimeString() + ` Server running at http:\/\/${hostname}:${port}`);\n    });\n\n})();\n<\/code><\/pre>\n\n\n\n<p>\u30af\u30e9\u30a4\u30a2\u30f3\u30c8(IP:192.168.2.100)\u304cChrome\u30d6\u30e9\u30a6\u30b6\u3067http:\/192.168.2.100:3000\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3068\u3001<\/p>\n\n\n\n<pre><code>\n[TYO] 2023-06-07(Wed) 13:50:17.527 TCP connection established. \u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u306eIP\u30a2\u30c9\u30ec\u30b9:192.168.2.100\n\u30bf\u30a4\u30e0\u30a2\u30a6\u30c8:2000\n[TYO] 2023-06-07(Wed) 13:50:19.542 TCP connection closed. \u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u306eIP\u30a2\u30c9\u30ec\u30b9:192.168.2.100\n[TYO] 2023-06-07(Wed) 13:50:22.536 TCP connection closed. \u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u306eIP\u30a2\u30c9\u30ec\u30b9:192.168.2.100\n<\/code><\/pre>\n\n\n\n<p>\u3068\u30b3\u30de\u30f3\u30c9\u30d7\u30ed\u30f3\u30d7\u30c8\u306b\u51fa\u308b\u3002<br>closed\u304c2\u56de\u51fa\u308b\u3002\u3053\u308c\u306f\u306a\u305c\u304b\uff1f<br>TCP\u30b3\u30cd\u30af\u30b7\u30e7\u30f3\u304c\u78ba\u7acb\u3055\u308c\u305f\u6642\u9593\u304b\u30892\u79d2\u5f8c\u306eclose\u304c\u30bf\u30a4\u30e0\u30a2\u30a6\u30c8\u306b\u3088\u308bclosed\u3067\u3042\u308b\u3002<br>\u305d\u3057\u3066\u3001TCP\u30b3\u30cd\u30af\u30b7\u30e7\u30f3\u304c\u78ba\u7acb\u3055\u308c\u305f\u6642\u9593\u304b\u30895\u79d2\u5f8c\u304c\u30af\u30ed\u30fc\u30e0\u306e\u30d6\u30e9\u30a6\u30b6\u304cTCP\u30b3\u30cd\u30af\u30b7\u30e7\u30f3\u3092\u9589\u3058\u305f\u3068\u304d\u306eclosed\u3067\u3042\u308b\u3002<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>\u30af\u30e9\u30a4\u30a2\u30f3\u30c8(IP:192.168.2.101)\u304cChrome\u30d6\u30e9\u30a6\u30b6\u3067http:\/192.168.2.100:3000\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3068\u3001<\/p>\n\n\n\n<pre><code>\n[TYO] 2023-06-07(Wed) 14:05:25.641 TCP connection established. \u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u306eIP\u30a2\u30c9\u30ec\u30b9:192.168.2.101\n\u30bf\u30a4\u30e0\u30a2\u30a6\u30c8:2000\n[TYO] 2023-06-07(Wed) 14:05:25.714 TCP connection closed. \u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u306eIP\u30a2\u30c9\u30ec\u30b9:192.168.2.101\n<\/code><\/pre>\n\n\n\n<p>\u3068\u30b3\u30de\u30f3\u30c9\u30d7\u30ed\u30f3\u30d7\u30c8\u306b\u51fa\u308b\u3002<br>\u4f55\u6545\u304b\u3001closed\u304c2\u56de\u51fa\u306a\u3044\u3002TCP\u30b3\u30cd\u30af\u30b7\u30e7\u30f3\u304c\u78ba\u7acb\u3055\u308c\u3066\u304b\u30892\u79d2\u5f8c\u304c\u30bf\u30a4\u30e0\u30a2\u30a6\u30c8\u306a\u306e\u3067\u3001\u30bf\u30a4\u30e0\u30a2\u30a6\u30c8\u306eclosed\u304c\u51fa\u3066\u3044\u306a\u3044\u3068\u3044\u3046\u3053\u3068\u306b\u306a\u308b\uff1f<br>closed\u304c1\u56de\u3057\u304b\u51fa\u306a\u3044\u539f\u56e0\u306f\u3069\u3046\u3084\u3063\u3066\u8abf\u67fb\u3059\u308b\u304b\u5206\u304b\u3089\u3093\u306a\u3002\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u306f\u96e3\u3057\u3044\u306a\u3002<br><br>\u95a2\u9023<br><a href=\"https:\/\/attacktube.com\/?p=1626\">HTTP\u901a\u4fe1 (attacktube.com)<\/a><br><a href=\"https:\/\/attacktube.com\/?p=2463\">\u3010Node.js\u3011http\u30b5\u30fc\u30d0\u30fc\u3092\u7acb\u3061\u4e0a\u3052\u308b (attacktube.com)<\/a><br><a href=\"https:\/\/attacktube.com\/?p=1809\">\u81ea\u5df1\u7f72\u540d\u8a3c\u660e\u66f8(\u30aa\u30ec\u30aa\u30ec\u8a3c\u660e\u66f8)\u3092\u4f7f\u3063\u3066HTTPS\u30b5\u30fc\u30d0\u30fc\u3092Node.js\u3067\u7acb\u3061\u4e0a\u3052\u308b(windows10) \u305d\u306e1 (attacktube.com)<\/a><br><a href=\"https:\/\/attacktube.com\/?p=2541\">\u81ea\u5df1\u7f72\u540d\u8a3c\u660e\u66f8(\u30aa\u30ec\u30aa\u30ec\u8a3c\u660e\u66f8)\u3092\u4f7f\u3063\u3066HTTPS\u30b5\u30fc\u30d0\u30fc\u3092Node.js\u3067\u7acb\u3061\u4e0a\u3052\u308b(windows10) \u305d\u306e2 (attacktube.com)<\/a><\/p>\n\n\n\n<script type=\"text\/javascript\">\njQuery(function($){\n$(\".jp-video\").hide();\n});\n<\/script>\n","protected":false},"excerpt":{"rendered":"<p>Node.js\u3067http\u30b5\u30fc\u30d0\u30fc\u3092\u7acb\u3061\u4e0a\u3052\u308b\u3002TCP\u63a5\u7d9a\u304c\u78ba\u7acb\u3055\u308c\u305f\u6642\u3068TCP\u63a5\u7d9a\u9589\u3058\u305f\u6642\u306b\u30b3\u30de\u30f3\u30c9\u30d7\u30ed\u30f3\u30d7\u30c8\u306b\u30ed\u30b0\u3092\u51fa\u3059\u3088\u3046\u306b\u3059\u308b\u3002\u305d\u308c\u3068\u3001keep-alive\u6a5f\u80fd\u3092\u7121\u52b9\u306b\u3059\u308b\u306b\u306fserver.keepAliveTim [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[6],"tags":[],"class_list":["post-2832","post","type-post","status-publish","format-standard","hentry","category-node-js"],"jetpack_featured_media_url":"","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/attacktube.com\/index.php?rest_route=\/wp\/v2\/posts\/2832","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/attacktube.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/attacktube.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/attacktube.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/attacktube.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2832"}],"version-history":[{"count":10,"href":"https:\/\/attacktube.com\/index.php?rest_route=\/wp\/v2\/posts\/2832\/revisions"}],"predecessor-version":[{"id":3896,"href":"https:\/\/attacktube.com\/index.php?rest_route=\/wp\/v2\/posts\/2832\/revisions\/3896"}],"wp:attachment":[{"href":"https:\/\/attacktube.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2832"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/attacktube.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2832"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/attacktube.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2832"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}