{"id":82996,"date":"2026-07-25T15:27:02","date_gmt":"2026-07-25T07:27:02","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/82996.html"},"modified":"2026-07-25T15:27:02","modified_gmt":"2026-07-25T07:27:02","slug":"linux-%e7%bd%91%e7%bb%9c%e5%a5%97%e6%8e%a5%e5%ad%97%e7%bc%96%e7%a8%8b%ef%bc%88%e4%b8%89%ef%bc%89udp%e6%9c%8d%e5%8a%a1%e5%99%a8%e4%b8%8e%e5%ae%a2%e6%88%b7%e7%ab%af%e5%ae%9e%e7%8e%b0%ef%bc%9awindows","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/82996.html","title":{"rendered":"Linux \u7f51\u7edc\u5957\u63a5\u5b57\u7f16\u7a0b\uff08\u4e09\uff09UDP\u670d\u52a1\u5668\u4e0e\u5ba2\u6237\u7aef\u5b9e\u73b0\uff1aWindows\u4e0eLinux\u901a\u4fe1\uff0c\u65b0\u589e\u5b57\u5178\u7ffb\u8bd1\u529f\u80fd\u7684 UDP \u901a\u4fe1"},"content":{"rendered":"<p id=\"main-toc\">\u76ee\u5f55<\/p>\n<p id=\"%E4%B8%80%E3%80%81Windows%E4%B8%8ELinux%E9%80%9A%E4%BF%A1-toc\" style=\"margin-left:0px\">\u4e00\u3001Windows\u4e0eLinux\u901a\u4fe1<\/p>\n<p id=\"Windows%20%E5%AE%A2%E6%88%B7%E7%AB%AF%E7%8E%AF%E5%A2%83%EF%BC%88VS2022%EF%BC%89-toc\" style=\"margin-left:40px\">Windows \u5ba2\u6237\u7aef\u73af\u5883&#xff08;VS2022&#xff09;<\/p>\n<p id=\"Linux%20%E6%9C%8D%E5%8A%A1%E7%AB%AF%E7%8E%AF%E5%A2%83%EF%BC%88Ubuntu%20%2B%20Xshell%EF%BC%89-toc\" style=\"margin-left:40px\">Linux \u670d\u52a1\u7aef\u73af\u5883&#xff08;Ubuntu &#043; Xshell&#xff09;<\/p>\n<p id=\"%E2%80%8B%E7%BC%96%E8%BE%91-toc\" style=\"margin-left:40px\">\u200b\u7f16\u8f91<\/p>\n<p id=\"%E8%BF%90%E8%A1%8C%E7%BB%93%E6%9E%9C%20%3A-toc\" style=\"margin-left:40px\">\u8fd0\u884c\u7ed3\u679c :<\/p>\n<p id=\"%E4%BA%8C%E3%80%81%E6%96%B0%E5%A2%9E%C2%A0Dict%20%E5%AD%97%E5%85%B8%E7%BF%BB%E8%AF%91%E6%A8%A1%E5%9D%97%E7%9A%84%C2%A0UDP%20%E9%80%9A%E4%BF%A1-toc\" style=\"margin-left:0px\">\u4e8c\u3001\u65b0\u589e\u00a0Dict \u5b57\u5178\u7ffb\u8bd1\u6a21\u5757\u7684\u00a0UDP \u901a\u4fe1<\/p>\n<p id=\"Dict%C2%A0%E7%B1%BB-toc\" style=\"margin-left:40px\">Dict\u00a0\u7c7b<\/p>\n<p id=\"Dict%20%E7%B1%BB%E6%95%B4%E4%BD%93%E7%BB%93%E6%9E%84-toc\" style=\"margin-left:40px\">Dict \u7c7b\u6574\u4f53\u7ed3\u6784<\/p>\n<p id=\"LoadDict()%EF%BC%9A%E4%BB%8E%E6%96%87%E4%BB%B6%E5%8A%A0%E8%BD%BD%E5%AD%97%E5%85%B8%E6%95%B0%E6%8D%AE-toc\" style=\"margin-left:80px\">LoadDict()&#xff1a;\u4ece\u6587\u4ef6\u52a0\u8f7d\u5b57\u5178\u6570\u636e<\/p>\n<p id=\"Translate()%EF%BC%9A%E5%AE%9E%E7%8E%B0%E6%A0%B8%E5%BF%83%E7%BF%BB%E8%AF%91%E9%80%BB%E8%BE%91-toc\" style=\"margin-left:80px\">Translate()&#xff1a;\u5b9e\u73b0\u6838\u5fc3\u7ffb\u8bd1\u903b\u8f91<\/p>\n<p id=\"EchoServer.hpp%20%E6%96%87%E4%BB%B6%E4%B8%AD%20UdpServer%20%E7%B1%BB%E7%9A%84%E6%94%B9%E9%80%A0-toc\" style=\"margin-left:40px\">EchoServer.hpp \u6587\u4ef6\u4e2d UdpServer \u7c7b\u7684\u6539\u9020<\/p>\n<p id=\"EchoServerMain.cc%20%E6%9C%8D%E5%8A%A1%E7%AB%AF%E5%85%A5%E5%8F%A3%E6%96%87%E4%BB%B6%E7%9A%84%E6%94%B9%E9%80%A0-toc\" style=\"margin-left:40px\">EchoServerMain.cc \u670d\u52a1\u7aef\u5165\u53e3\u6587\u4ef6\u7684\u6539\u9020<\/p>\n<p id=\"%E5%9B%9E%E8%B0%83%E7%9A%84%E4%BD%93%E7%8E%B0-toc\" style=\"margin-left:40px\">\u56de\u8c03\u7684\u4f53\u73b0<\/p>\n<p id=\"%E8%BF%90%E8%A1%8C%E7%BB%93%E6%9E%9C%20%3A-toc\" style=\"margin-left:40px\">\u8fd0\u884c\u7ed3\u679c :<\/p>\n<p id=\"%E4%BB%A3%E7%A0%81%3A-toc\" style=\"margin-left:40px\">\u4ee3\u7801:<\/p>\n<p id=\"%E2%80%8B%E7%BC%96%E8%BE%91-toc\" style=\"margin-left:40px\">\u200b\u7f16\u8f91<\/p>\n<p id=\"%E4%B8%89%E3%80%81%E6%80%BB%E7%BB%93-toc\" style=\"margin-left:0px\">\u4e09\u3001\u603b\u7ed3<\/p>\n<hr \/>\n<p>\u6211\u4eec\u63a5\u7740\u4e0a\u4e00\u7bc7\u6587\u7ae0\u6211\u4eec\u5199\u7684 UDP \u670d\u52a1\u7aef\u4e0e\u5ba2\u6237\u7aef\u7684\u901a\u4fe1&#xff0c;\u4e4b\u524d\u6211\u4eec\u6240\u6709\u7684\u7f51\u7edc\u64cd\u4f5c\u3001\u8c03\u8bd5\u3001\u901a\u4fe1\u903b\u8f91&#xff0c;\u5168\u90e8\u90fd\u5728 Linux \u73af\u5883\u4e0b\u5b8c\u6210\u3002\u4e0d\u7ba1\u662f\u672c\u5730\u56de\u73af\u3001\u516c\u7f51\u8bbf\u95ee&#xff0c;\u8fd8\u662f\u4e0d\u540c Linux \u673a\u5668\u4e4b\u95f4\u7684\u4e92\u901a\u3002  \u90a3 Windows \u80fd\u4e0d\u80fd\u548c Linux \u4e92\u76f8\u901a\u4fe1&#xff1f;Windows \u7535\u8111\u4e0a\u7684\u7a0b\u5e8f&#xff0c;\u80fd\u4e0d\u80fd\u901a\u8fc7\u7f51\u7edc&#xff0c;\u76f4\u63a5\u7ed9 Linux \u673a\u5668\u53d1\u6570\u636e&#xff1f;<\/p>\n<p>\u7b54\u6848\u662f&#xff1a;\u5b8c\u5168\u53ef\u4ee5&#xff01;\u800c\u4e14\u53ea\u8981\u9075\u5faa\u6807\u51c6\u7684 Socket \u63a5\u53e3&#xff08;\u4e0d\u7ba1\u662f Windows \u8fd8\u662f Linux&#xff09;&#xff0c;\u4e24\u8005\u53ef\u4ee5\u5b9e\u73b0\u5b8c\u5168\u4e92\u901a\u3002<\/p>\n<p>\u4e0b\u9762\u6211\u4eec\u5c31\u6765\u9a8c\u8bc1\u4e00\u4e0b :<\/p>\n<h2 id=\"%E4%B8%80%E3%80%81Windows%E4%B8%8ELinux%E9%80%9A%E4%BF%A1\" style=\"background-color:transparent\">\u4e00\u3001Windows\u4e0eLinux\u901a\u4fe1<\/h2>\n<p>\u4e0b\u9762\u6211\u4eec\u642d\u5efa\u4e00\u4e2a\u8de8\u64cd\u4f5c\u7cfb\u7edf\u7684\u771f\u5b9e\u901a\u4fe1\u73af\u5883\u3002\u5176\u4e2d&#xff0c;\u5ba2\u6237\u7aef\u8fd0\u884c\u5728 Windows \u4e0a&#xff0c;\u800c\u670d\u52a1\u7aef\u7ee7\u7eed\u8fd0\u884c\u5728 Linux \u4e0a\u3002<\/p>\n<h3 id=\"Windows%20%E5%AE%A2%E6%88%B7%E7%AB%AF%E7%8E%AF%E5%A2%83%EF%BC%88VS2022%EF%BC%89\">Windows \u5ba2\u6237\u7aef\u73af\u5883&#xff08;VS2022&#xff09;<\/h3>\n<p>\u6211\u4eec\u5728 Windows \u5e73\u53f0\u4e0b\u5f00\u53d1\u5e76\u8fd0\u884c\u5ba2\u6237\u7aef\u7a0b\u5e8f&#xff0c;\u7528\u5230\u7684\u5f00\u53d1\u5de5\u5177\u662f Visual Studio 2022&#xff0c;VS2022 \u662f Windows \u5e73\u53f0\u4e0b\u6700\u4e3b\u6d41\u3001\u6700\u5f3a\u5927\u7684 IDE \u4e4b\u4e00&#xff0c;\u7528\u4e8e\u5f00\u53d1 C\/C&#043;&#043;\u7b49\u5e94\u7528\u3002\u5b83\u5185\u7f6e Windows \u7279\u6709\u7684 Winsock \u7f51\u7edc\u5e93&#xff0c;\u63d0\u4f9b\u6807\u51c6\u7684 BSD Socket \u63a5\u53e3\u5c01\u88c5\u3002<\/p>\n<p>\u8fd9\u91cc\u6211\u4eec\u76f4\u63a5\u628a Windows \u4e0b\u7684\u4ee3\u7801\u590d\u5236\u7c98\u8d34\u8fc7\u6765\u4f7f\u7528 :<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1730\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/07\/20260725072655-6a64653f10724.png\" width=\"1361\" \/><\/p>\n<p>\u5ba2\u6237\u7aef\u7a0b\u5e8f&#xff1a;\u4f7f\u7528 C\/C&#043;&#043; \u7f16\u5199&#xff0c;\u8c03\u7528 socket()\u3001sendto()\u3001recvfrom() \u7b49\u6807\u51c6 Socket \u63a5\u53e3\u3002<span style=\"color:#fe2c24\">\u5411 Linux \u670d\u52a1\u7aef\u7684 \u516c\u7f51 IP &#034;124.222.191.171&#034;&#043; 8080 \u7aef\u53e3<\/span> \u53d1\u9001 UDP \u6570\u636e<\/p>\n<p>\u867d\u7136 Windows \u548c Linux \u7684\u5e95\u5c42\u7f51\u7edc\u5b50\u7cfb\u7edf\u4e0d\u540c&#xff0c;\u4f46 Socket \u63a5\u53e3\u5c42\u9762\u5b9e\u73b0\u4e86\u8de8\u5e73\u53f0\u6807\u51c6\u5316\u3002\u56e0\u6b64&#xff0c;\u6211\u4eec\u5199\u7684\u5ba2\u6237\u7aef\u4ee3\u7801\u51e0\u4e4e\u4e0d\u9700\u8981\u4fee\u6539&#xff0c;\u5c31\u80fd\u5728 Windows \u4e0a\u7f16\u8bd1\u3001\u8fd0\u884c\u3001\u76f4\u63a5\u53d1\u6570\u636e\u7ed9 Linux\u3002<\/p>\n<h3 id=\"Linux%20%E6%9C%8D%E5%8A%A1%E7%AB%AF%E7%8E%AF%E5%A2%83%EF%BC%88Ubuntu%20%2B%20Xshell%EF%BC%89\">Linux \u670d\u52a1\u7aef\u73af\u5883&#xff08;Ubuntu &#043; Xshell&#xff09;<\/h3>\n<p>\u670d\u52a1\u7aef\u7ee7\u7eed\u4fdd\u6301\u6211\u4eec\u719f\u6089\u7684 Linux \u73af\u5883 : \u901a\u8fc7 Xshell \u8fdc\u7a0b\u8fde\u63a5 Linux \u4e91\u670d\u52a1\u5668<\/p>\n<p>Linux \u670d\u52a1\u7aef\u4f7f\u7528\u6807\u51c6\u7684 POSIX Socket&#xff0c;\u901a\u8fc7 bind\u3001recvfrom\u3001sendto \u7b49\u63a5\u53e3\u63a5\u53d7\u5ba2\u6237\u7aef\u8bf7\u6c42&#xff0c;\u4e0d\u533a\u5206\u5ba2\u6237\u7aef\u64cd\u4f5c\u7cfb\u7edf&#xff0c;\u53ea\u6839\u636e IP &#043; \u7aef\u53e3 \u5339\u914d\u6570\u636e\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"3054\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/07\/20260725072656-6a64654013e11.png\" width=\"1417\" \/><\/p>\n<h3 id=\"%E2%80%8B%E7%BC%96%E8%BE%91\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"819\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/07\/20260725072658-6a646542163b1.png\" width=\"1275\" \/><\/h3>\n<h3 id=\"%E8%BF%90%E8%A1%8C%E7%BB%93%E6%9E%9C%20%3A\">\u8fd0\u884c\u7ed3\u679c :<\/h3>\n<p>\u6211\u4eec\u5148\u8fd0\u884c Windows \u4e0b\u7684 VS2022 \u7684\u5ba2\u6237\u7aef&#xff0c;\u8fd0\u884c\u5b8c\u540e\u5411 Linux \u4e2d\u7684\u670d\u52a1\u7aef\u8f93\u5165&#034;hello Linux&#034; :<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"360\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/07\/20260725072658-6a64654269831.png\" width=\"1263\" \/><\/p>\n<p>\u6309\u4e0b\u56de\u8f66\u540e&#xff0c;Linux \u4e0b\u7684\u670d\u52a1\u7aef\u6536\u5230\u4e86 Windows \u4e0b\u7684\u5ba2\u6237\u7aef\u53d1\u6765\u7684\u6d88\u606f :<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"317\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/07\/20260725072658-6a64654295250.png\" width=\"1353\" \/><\/p>\n<p>\u6b64\u65f6\u6211\u4eec\u5c31\u5b8c\u6210\u4e86 Windows \u4e0e Linux \u4e4b\u95f4\u7684\u901a\u4fe1\u3002<\/p>\n<h2 id=\"%E4%BA%8C%E3%80%81%E6%96%B0%E5%A2%9E%C2%A0Dict%20%E5%AD%97%E5%85%B8%E7%BF%BB%E8%AF%91%E6%A8%A1%E5%9D%97%E7%9A%84%C2%A0UDP%20%E9%80%9A%E4%BF%A1\" style=\"background-color:transparent\">\u4e8c\u3001\u65b0\u589e\u00a0Dict \u5b57\u5178\u7ffb\u8bd1\u6a21\u5757\u7684\u00a0UDP \u901a\u4fe1<\/h2>\n<p>\u4e0a\u4e00\u7bc7\u6587\u7ae0\u4e2d\u6211\u4eec\u5b9e\u73b0\u4e86 UDP \u670d\u52a1\u7aef\u548c\u5ba2\u6237\u7aef\u7684\u901a\u4fe1&#xff0c;\u4f46\u662f\u8fd9\u79cd\u901a\u4fe1\u4e5f\u4ec5\u5b8c\u6210\u4e86\u57fa\u7840\u7684\u7f51\u7edc IO \u56de\u58f0\u4ea4\u4e92&#xff1a;\u670d\u52a1\u7aef\u53ea\u8d1f\u8d23\u63a5\u6536\u5ba2\u6237\u7aef\u6d88\u606f\u3001\u539f\u6837\u62fc\u63a5\u524d\u7f00\u540e\u56de\u53d1&#xff0c;\u6838\u5fc3\u903b\u8f91\u96c6\u4e2d\u5728\u7f51\u7edc\u6536\u53d1\u672c\u8eab&#xff0c;\u6ca1\u6709\u989d\u5916\u4e1a\u52a1\u5904\u7406\u80fd\u529b\u3002<\/p>\n<p>\u800c\u5728\u771f\u5b9e\u5f00\u53d1\u573a\u666f\u4e2d&#xff0c;\u7f51\u7edc\u670d\u52a1\u7684\u6838\u5fc3\u4ef7\u503c\u662f\u627f\u8f7d\u4e0a\u5c42\u4e1a\u52a1\u903b\u8f91&#xff0c;\u7f51\u7edc IO \u4ec5\u4f5c\u4e3a\u6570\u636e\u4f20\u8f93\u901a\u9053\u3002\u57fa\u4e8e\u6b64&#xff0c;\u6211\u4eec\u5bf9\u539f\u6709 UDP \u670d\u52a1\u7aef\u67b6\u6784\u8fdb\u884c\u5206\u5c42\u5347\u7ea7&#xff1a;\u5728\u539f\u6709\u7684\u670d\u52a1\u7aef\u7f51\u7edc IO \u6a21\u5757\u4e0a\u5c42&#xff0c;\u65b0\u589e Dict \u5b57\u5178\u7ffb\u8bd1\u4e1a\u52a1\u6a21\u5757&#xff0c;\u5f62\u6210\u6e05\u6670\u7684\u4e24\u5c42\u67b6\u6784&#xff1a;<\/p>\n<p>\u00a0 \u00a01. \u5e95\u5c42&#xff1a;\u670d\u52a1\u7aef\u6a21\u5757&#xff0c;\u4e13\u6ce8\u5904\u7406 UDP \u7f51\u7edc IO&#xff0c;\u8d1f\u8d23\u63a5\u6536\u5ba2\u6237\u7aef\u7f51\u7edc\u6570\u636e\u3001\u5411\u4e0a\u5c42\u4ea4\u4ed8\u539f\u59cb\u6d88\u606f\u3001\u63a5\u6536\u4e0a\u5c42\u5904\u7406\u7ed3\u679c\u5e76\u901a\u8fc7\u7f51\u7edc\u56de\u53d1\u7ed9\u5ba2\u6237\u7aef&#xff1b;<\/p>\n<\/p>\n<p>\u00a0 \u00a02. \u4e0a\u5c42&#xff1a;Dict \u7ffb\u8bd1\u6a21\u5757&#xff0c;\u4e13\u6ce8\u5b9e\u73b0\u4e1a\u52a1\u903b\u8f91&#xff0c;\u63a5\u6536\u5e95\u5c42\u4f20\u9012\u7684\u539f\u59cb\u6d88\u606f&#xff0c;\u5b8c\u6210\u5b57\u5178\u7ffb\u8bd1\u8ba1\u7b97\u540e&#xff0c;\u5c06\u7ffb\u8bd1\u7ed3\u679c\u56de\u4f20\u7ed9\u7f51\u7edc\u5c42\u3002<\/p>\n<p>\u5347\u7ea7\u540e\u7684\u6570\u636e\u6d41\u8f6c\u94fe\u8def\u4e25\u683c\u9075\u5faa\u5206\u5c42\u8c03\u7528\u903b\u8f91&#xff1a;\u5ba2\u6237\u7aef\u53d1\u9001\u7684\u6d88\u606f&#xff0c;\u5148\u7531\u670d\u52a1\u7aef\u5b8c\u6210\u7f51\u7edc\u5c42\u9762\u7684\u63a5\u6536&#xff0c;\u4ea4\u4ed8\u7ed9\u4e0a\u5c42 Dict \u6a21\u5757\u8fdb\u884c\u7ffb\u8bd1\u5904\u7406&#xff1b;\u7ffb\u8bd1\u5b8c\u6210\u540e&#xff0c;\u5904\u7406\u7ed3\u679c\u539f\u8def\u8fd4\u56de\u7f51\u7edc IO \u5c42&#xff0c;\u518d\u7531\u670d\u52a1\u7aef\u901a\u8fc7 UDP \u534f\u8bae\u56de\u53d1\u7ed9\u5ba2\u6237\u7aef\u3002<\/p>\n<h3 id=\"Dict%C2%A0%E7%B1%BB\" style=\"background-color:transparent\">Dict\u00a0\u7c7b<\/h3>\n<p>\u4e4b\u524d\u7684 UDP \u56de\u58f0\u670d\u52a1\u4e2d&#xff0c;\u670d\u52a1\u7aef\u6536\u5230\u6570\u636e\u540e&#xff0c;\u76f4\u63a5\u5728 Start() \u51fd\u6570\u91cc\u62fc\u63a5\u5b57\u7b26\u4e32\u56de\u53d1&#xff0c;\u4e1a\u52a1\u548c\u7f51\u7edc\u6536\u53d1\u903b\u8f91\u662f\u8026\u5408\u5728\u4e00\u8d77\u7684\u3002\u5982\u679c\u60f3\u628a\u56de\u58f0\u6539\u6210\u5176\u4ed6\u529f\u80fd&#xff0c;\u6bd4\u5982\u8ba1\u7b97\u5668\u3001\u7ffb\u8bd1\u5668&#xff0c;\u5c31\u5fc5\u987b\u4fee\u6539\u670d\u52a1\u7aef\u7684\u4ee3\u7801&#xff0c;\u5bfc\u81f4\u6269\u5c55\u6027\u5f88\u5dee\u3002<\/p>\n<p>\u6240\u4ee5\u4e3a\u4e86\u89e3\u8026&#xff0c;\u6211\u4eec\u65b0\u589e\u4e86\u4e00\u4e2a Dict.hpp \u6587\u4ef6&#xff0c;\u91cc\u9762\u5c01\u88c5\u4e86\u4e00\u4e2a\u7684 Dict \u7c7b&#xff0c;\u4e13\u95e8\u8d1f\u8d23\u5b57\u5178\u7ffb\u8bd1\u7684\u4e1a\u52a1\u903b\u8f91&#xff0c;\u8ba9\u7f51\u7edc\u5c42\u548c\u4e1a\u52a1\u5c42\u5f7b\u5e95\u5206\u5f00\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1886\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/07\/20260725072658-6a646542bc8cd.png\" width=\"1391\" \/><\/p>\n<h3 id=\"Dict%20%E7%B1%BB%E6%95%B4%E4%BD%93%E7%BB%93%E6%9E%84\">Dict \u7c7b\u6574\u4f53\u7ed3\u6784<\/h3>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"626\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/07\/20260725072659-6a646543a7769.png\" width=\"1236\" \/><\/p>\n<h4 id=\"LoadDict()%EF%BC%9A%E4%BB%8E%E6%96%87%E4%BB%B6%E5%8A%A0%E8%BD%BD%E5%AD%97%E5%85%B8%E6%95%B0%E6%8D%AE\">LoadDict()&#xff1a;\u4ece\u6587\u4ef6\u52a0\u8f7d\u5b57\u5178\u6570\u636e<\/h4>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"789\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/07\/20260725072659-6a646543eb349.png\" width=\"1324\" \/><\/p>\n<h4 id=\"Translate()%EF%BC%9A%E5%AE%9E%E7%8E%B0%E6%A0%B8%E5%BF%83%E7%BF%BB%E8%AF%91%E9%80%BB%E8%BE%91\">Translate()&#xff1a;\u5b9e\u73b0\u6838\u5fc3\u7ffb\u8bd1\u903b\u8f91<\/h4>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"350\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/07\/20260725072700-6a6465444b1bf.png\" width=\"1129\" \/>Translate() \u51fd\u6570\u7684\u8fd4\u56de\u503c\u548c\u53c2\u6570\u7c7b\u578b\u90fd\u662f\u00a0std::string&#xff0c;\u521a\u597d\u548c\u6211\u4eec\u540e\u9762\u8981\u5b9a\u4e49\u7684 callback_t \u56de\u8c03\u7c7b\u578b\u5b8c\u5168\u5339\u914d\u3002\u8fd9\u610f\u5473\u7740&#xff0c;\u6211\u4eec\u53ef\u4ee5\u76f4\u63a5\u628a Dict::Translate \u4f5c\u4e3a\u56de\u8c03\u51fd\u6570&#xff0c;\u6ce8\u5165\u5230 UdpServer \u4e2d&#xff0c;\u8ba9\u7f51\u7edc\u5c42\u8c03\u7528\u5b83\u6765\u5904\u7406\u6570\u636e\u3002<\/p>\n<h3 id=\"EchoServer.hpp%20%E6%96%87%E4%BB%B6%E4%B8%AD%20UdpServer%20%E7%B1%BB%E7%9A%84%E6%94%B9%E9%80%A0\">EchoServer.hpp \u6587\u4ef6\u4e2d UdpServer \u7c7b\u7684\u6539\u9020<\/h3>\n<p>EchoServer.hpp \u6587\u4ef6\u662f\u6539\u52a8\u6700\u5927\u7684\u6587\u4ef6&#xff0c;\u4ece\u7eaf\u56de\u58f0\u670d\u52a1\u6539\u6210\u4e86\u652f\u6301\u56de\u8c03\u6ce8\u5165\u7684\u901a\u7528 UDP \u670d\u52a1\u6846\u67b6\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"64\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/07\/20260725072700-6a64654475c74.png\" width=\"1052\" \/>\u9996\u5148\u6211\u4eec\u65b0\u589e\u4e86\u56de\u8c03\u7c7b\u578b\u5b9a\u4e49&#xff0c;\u5b9a\u4e49\u4e86\u4e00\u4e2a\u51fd\u6570\u7b7e\u540d&#xff1a;\u63a5\u6536 std::string&#xff0c;\u8fd4\u56de std::string\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"176\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/07\/20260725072700-6a64654486878.png\" width=\"1345\" \/>\u540c\u65f6\u65b0\u589e\u4e86\u6210\u5458\u53d8\u91cf callback_t _cb&#xff0c;\u7528\u6765\u4fdd\u5b58\u6ce8\u5165\u7684\u4e1a\u52a1\u56de\u8c03&#xff08;\u4e5f\u5c31\u662f Dict::Translate)&#xff0c;\u8ba9 Start() \u5faa\u73af\u91cc\u80fd\u968f\u65f6\u8c03\u7528\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"181\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/07\/20260725072700-6a646544a893a.png\" width=\"885\" \/>\u540c\u65f6\u4e5f\u8981\u4fee\u6539\u6784\u9020\u51fd\u6570&#xff0c;\u652f\u6301\u6ce8\u5165\u56de\u8c03&#xff0c;\u65b0\u589e\u4e86 callback_t cb \u53c2\u6570&#xff0c;\u628a\u4e0a\u5c42\u4e1a\u52a1\u903b\u8f91 \u201c\u6ce8\u5165\u201d \u5230\u7f51\u7edc\u5c42&#xff0c;_cb \u4f5c\u4e3a\u6210\u5458\u53d8\u91cf\u4fdd\u5b58&#xff0c;\u540e\u9762 Start() \u4e2d\u8c03\u7528\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"197\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/07\/20260725072700-6a646544bca1f.png\" width=\"1190\" \/> Start() \u65b9\u6cd5\u66ff\u6362\u56de\u58f0\u903b\u8f91\u4e3a\u56de\u8c03\u8c03\u7528&#xff0c;\u539f\u6765\u6536\u5230\u6570\u636e\u540e&#xff0c;\u76f4\u63a5\u62fc\u63a5\u5b57\u7b26\u4e32\u56de\u53d1&#xff0c;\u73b0\u5728\u6536\u5230\u6570\u636e\u540e&#xff0c;\u5148\u8c03\u7528 _cb \u5904\u7406\u6570\u636e&#xff0c;\u62ff\u5230\u5904\u7406\u7ed3\u679c\u518d\u56de\u53d1&#xff0c;\u8fd9\u6837\u7f51\u7edc\u5c42\u5c31\u548c\u5177\u4f53\u4e1a\u52a1\u65e0\u5173\u4e86&#xff0c;\u53ea\u8d1f\u8d23\u6536\u53d1\u548c\u8c03\u7528\u56de\u8c03&#xff0c;\u4ece\u800c\u5b9e\u73b0\u89e3\u8026\u3002<\/p>\n<h3 id=\"EchoServerMain.cc%20%E6%9C%8D%E5%8A%A1%E7%AB%AF%E5%85%A5%E5%8F%A3%E6%96%87%E4%BB%B6%E7%9A%84%E6%94%B9%E9%80%A0\" style=\"background-color:transparent\">EchoServerMain.cc \u670d\u52a1\u7aef\u5165\u53e3\u6587\u4ef6\u7684\u6539\u9020<\/h3>\n<p>EchoServerMain.cc \u6587\u4ef6\u7ed1\u5b9a\u4e86\u7f51\u7edc\u5c42\u548c\u4e1a\u52a1\u5c42&#xff0c;\u662f\u628a Dict \u548c UdpServer \u8fde\u8d77\u6765\u7684\u80f6\u6c34\u4ee3\u7801\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"624\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/07\/20260725072700-6a646544d8d52.png\" width=\"1323\" \/><\/p>\n<p>\u9996\u5148\u5b9a\u4e49\u4e86\u4e00\u4e2a dict \u5bf9\u8c61&#xff0c;\u7528 Lambda \u8868\u8fbe\u5f0f\u6355\u83b7 dict \u5bf9\u8c61&#xff0c;\u628a dict.Translate() \u9002\u914d\u6210 callback_t \u7c7b\u578b&#xff0c;\u8fd9\u6837 UdpServer \u542f\u52a8\u540e&#xff0c;\u6bcf\u6b21\u6536\u5230\u6570\u636e\u90fd\u4f1a\u8c03\u7528\u901a\u8fc7 _cb \u6765\u56de\u8c03\u8fd9\u4e2a\u00a0Lambda&#xff0c;\u4ece\u800c\u95f4\u63a5\u8c03\u7528 dict.Translate() \u662f\u897f\u5b89\u7ffb\u8bd1\u529f\u80fd\u3002<\/p>\n<p>EchoClient.cc \u5ba2\u6237\u7aef\u6587\u4ef6\u4e0d\u505a\u4efb\u4f55\u6539\u52a8&#xff0c;\u56e0\u4e3a\u5ba2\u6237\u7aef\u53ea\u8d1f\u8d23\u53d1\u5b57\u7b26\u4e32\u3001\u6536\u5b57\u7b26\u4e32&#xff0c;\u5b83\u672c\u4e0d\u77e5\u9053\u670d\u52a1\u7aef\u73b0\u5728\u662f\u56de\u58f0\u8fd8\u662f\u7ffb\u8bd1&#xff0c;\u7f51\u7edc\u534f\u8bae&#xff08;UDP&#xff09;\u3001\u6570\u636e\u683c\u5f0f&#xff08;\u5b57\u7b26\u4e32&#xff09;\u6ca1\u53d8&#xff0c;\u6240\u4ee5\u5ba2\u6237\u7aef\u4e0d\u7528\u6539\u3002<\/p>\n<h3 id=\"%E5%9B%9E%E8%B0%83%E7%9A%84%E4%BD%93%E7%8E%B0\" style=\"background-color:transparent\">\u56de\u8c03\u7684\u4f53\u73b0<\/h3>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"50\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/07\/20260725072701-6a6465452441a.png\" width=\"894\" \/>\u5148\u5b9a\u4e49\u56de\u8c03\u51fd\u6570\u7c7b\u578b&#xff0c;\u5b9a\u4e49\u4e00\u4e2a\u53eb callback_t \u7684 \u201c\u51fd\u6570\u7c7b\u578b\u201d&#xff0c;\u8981\u6c42\u8fd9\u4e2a\u51fd\u6570\u5fc5\u987b&#xff1a;\u63a5\u6536 1 \u4e2a std::string \u53c2\u6570&#xff0c;\u8fd4\u56de 1 \u4e2a std::string \u7ed3\u679c\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"172\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/07\/20260725072701-6a646545307bd.png\" width=\"886\" \/>\u8fd9\u91cc\u7684 _cb(cb) \u5c31\u662f\u5173\u952e&#xff1a;\u6211\u4eec\u521b\u5efa UdpServer \u65f6&#xff0c;\u4f1a\u628a\u4e00\u4e2a\u7b26\u5408 callback_t \u7c7b\u578b\u7684\u51fd\u6570\u4f20\u8fdb\u6765 \u6784\u9020\u51fd\u6570\u628a\u8fd9\u4e2a\u51fd\u6570\u4fdd\u5b58\u5230\u6210\u5458\u53d8\u91cf _cb \u91cc&#xff0c;\u4ece\u6b64&#xff0c;UdpServer \u91cc\u5c31\u5b58\u4e86\u4e00\u4e2a \u201c\u672a\u6765\u8981\u8c03\u7528\u7684\u4e1a\u52a1\u51fd\u6570\u201d&#xff0c;\u4f46\u73b0\u5728\u8fd8\u6ca1\u6267\u884c\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"131\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/07\/20260725072701-6a64654543998.png\" width=\"1047\" \/>\u670d\u52a1\u7aef\u6536\u5230\u6570\u636e\u65f6&#xff1a;\u8c03\u7528\u56de\u8c03\u51fd\u6570\u5904\u7406\u6570\u636e&#xff0c;\u7f51\u7edc\u5c42 UdpServer \u6536\u5230\u6570\u636e\u540e&#xff0c;\u4e0d\u81ea\u5df1\u5904\u7406&#xff0c;\u800c\u662f\u8c03\u7528 _cb&#xff0c;\u628a\u6536\u5230\u7684 inbuffer \u4f20\u7ed9 _cb&#xff0c;\u62ff\u5230\u8fd4\u56de\u7684 result&#xff0c;\u518d\u628a result \u56de\u53d1\u7ed9\u5ba2\u6237\u7aef&#xff0c;\u8fd9\u4e00\u6b65\u91cc&#xff0c;UdpServer \u6839\u672c\u4e0d\u77e5\u9053 _cb \u91cc\u9762\u662f\u4ec0\u4e48\u903b\u8f91&#xff0c;\u5b83\u53ea\u77e5\u9053&#xff1a;\u201c\u6211\u6536\u5230\u6570\u636e&#xff0c;\u6309\u6807\u51c6\u683c\u5f0f\u8c03\u7528 _cb&#xff0c;\u62ff\u5230\u7ed3\u679c\u53d1\u56de\u53bb\u5c31\u884c\u3002\u201d<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"138\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/07\/20260725072701-6a6465455c261.png\" width=\"1334\" \/> \u8fd9\u91cc\u662f\u628a Dict \u7ffb\u8bd1\u903b\u8f91&#xff0c;\u5305\u88c5\u6210\u7b26\u5408 callback_t \u6807\u51c6\u7684\u51fd\u6570&#xff0c;\u4f20\u7ed9 UdpServer&#xff1a;\u7528\u4e00\u4e2a Lambda \u8868\u8fbe\u5f0f\u6355\u83b7 dict \u5bf9\u8c61&#xff0c;Lambda \u7684\u7b7e\u540d\u662f std::string(std::string)&#xff0c;\u521a\u597d\u5339\u914d callback_t&#xff0c;\u91cc\u9762\u5b9e\u9645\u6267\u884c\u7684\u662f dict.Translate(word)&#xff0c;\u628a\u7ffb\u8bd1\u7ed3\u679c\u8fd4\u56de&#xff0c;\u5f53 UdpServer \u8c03\u7528 _cb(inbuffer) \u65f6&#xff0c;\u5b9e\u9645\u6267\u884c\u7684\u5c31\u662f\u8fd9\u4e2a Lambda&#xff0c;\u518d\u7531 Lambda \u53bb\u8c03\u7528 dict.Translate\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"341\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/07\/20260725072701-6a64654572aa3.png\" width=\"898\" \/>\u8fd9\u5c31\u662f\u56de\u8c03\u51fd\u6570\u7684 \u201c\u672c\u4f53\u201d&#xff1a;\u63a5\u6536 Lambda \u4f20\u8fc7\u6765\u7684 word&#xff0c;\u5728 _dict \u91cc\u67e5\u627e\u5355\u8bcd&#xff0c;\u8fd4\u56de\u4e2d\u6587\u91ca\u4e49\u6216 &#034;None&#034;<\/p>\n<p>\u6570\u636e\u6d41\u8f6c\u94fe\u8def<\/p>\n<p>\u5ba2\u6237\u7aef\u53d1\u9001 apple \u2192 \u7f51\u7edc \u2192 \u670d\u52a1\u7aef\u2192 \u670d\u52a1\u7aef UdpServer::recvfrom \u6536\u5230\u6570\u636e \u2192 \u8c03\u7528\u6ce8\u5165\u7684\u56de\u8c03 dict.Translate(&#034;apple&#034;) \u2192\u00a0Translate \u65b9\u6cd5\u8fd4\u56de\u7ed3\u679c \u2192 UdpServer::sendto \u628a\u7ed3\u679c\u56de\u53d1\u7ed9\u5ba2\u6237\u7aef \u2192 \u5ba2\u6237\u7aef\u6536\u5230\u5e76\u6253\u5370<\/p>\n<h3 id=\"%E8%BF%90%E8%A1%8C%E7%BB%93%E6%9E%9C%20%3A\">\u8fd0\u884c\u7ed3\u679c :<\/h3>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"668\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/07\/20260725072701-6a6465458dadb.png\" width=\"1279\" \/>\u56e0\u4e3a\u6267\u884c\u670d\u52a1\u7aef\u662f\u5b9a\u4e49\u4e86 dict \u5bf9\u8c61&#xff0c;\u6240\u4ee5\u4f1a\u5148\u6267\u884c dict \u7684\u6784\u9020\u51fd\u6570&#xff0c;\u6784\u9020\u51fd\u6570\u91cc\u53c8\u6709\u52a0\u8f7d\u51fd\u6570&#xff0c;\u52a0\u8f7d\u51fd\u6570\u4f1a\u5148\u901a\u8fc7\u65e5\u5fd7\u6253\u5370\u51fa\u5b57\u5178\u6587\u4ef6\u4e2d\u7684\u5185\u5bb9&#xff0c;\u52a0\u8f7d\u5b8c\u6bd5\u540e\u7ee7\u7eed\u5411\u540e\u6267\u884c&#xff0c;\u6267\u884c Init()\u548c Start() \u51fd\u6570\u3002<\/p>\n<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"186\" src=\"2026-07-25fjm3gehleks.png\" width=\"1106\" \/><\/p>\n<p>\u6210\u529f\u7ffb\u8bd1!<\/p>\n<h3 id=\"%E4%BB%A3%E7%A0%81%3A\" style=\"background-color:transparent\">\u4ee3\u7801:<\/h3>\n<h3 id=\"%E2%80%8B%E7%BC%96%E8%BE%91\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"41\" src=\"2026-07-25ej12mnizojq.png\" width=\"1118\" \/><\/h3>\n<p>Dict.hpp:<\/p>\n<p>#pragma once<\/p>\n<p>#include &lt;iostream&gt;<br \/>\n#include &lt;string&gt;<br \/>\n#include &lt;fstream&gt;<br \/>\n#include &lt;unordered_map&gt;<br \/>\n#include &#034;Logger.hpp&#034;<\/p>\n<p>static const std::string default_dict &#061; &#034;.\/dict.txt&#034;;<br \/>\nstatic const std::string sep &#061; &#034;: &#034;;<br \/>\nusing namespace NS_LOG_MODULE;<\/p>\n<p>class Dict<br \/>\n{<br \/>\npublic:<br \/>\n    Dict(const std::string &amp;dict_path &#061; default_dict) : _dict_path(dict_path)<br \/>\n    {<br \/>\n        LoadDict();<br \/>\n    }<br \/>\n    ~Dict()<br \/>\n    {<br \/>\n    }<br \/>\n    void LoadDict()<br \/>\n    {<br \/>\n        std::ifstream in(_dict_path);<br \/>\n        if (!in.is_open())<br \/>\n        {<br \/>\n            LOG(LogLevel::FATAL) &lt;&lt; &#034; open &#034; &lt;&lt; _dict_path &lt;&lt; &#034; error&#034;;<br \/>\n            exit(1);<br \/>\n        }<br \/>\n        std::string line;<br \/>\n        while (std::getline(in, line))<br \/>\n        {<br \/>\n            LOG(LogLevel::FATAL) &lt;&lt; &#034;load: &#034; &lt;&lt; line &lt;&lt; &#034; success&#034;;<br \/>\n            \/\/ apple: \u82f9\u679c<br \/>\n            auto pos &#061; line.find(sep);<br \/>\n            if (pos &#061;&#061; std::string::npos)<br \/>\n            {<br \/>\n                LOG(LogLevel::WARNING) &lt;&lt; &#034;Format: &#034; &lt;&lt; line &lt;&lt; &#034; error&#034;;<br \/>\n                continue;<br \/>\n            }<\/p>\n<p>            std::string k &#061; line.substr(0, pos); \/\/ [)<br \/>\n            std::string v &#061; line.substr(pos &#043; sep.size());<br \/>\n            _dict.insert(std::make_pair(k, v));<br \/>\n        }<\/p>\n<p>        in.close();<br \/>\n        LOG(LogLevel::INFO) &lt;&lt; &#034;load done&#8230;.&#034;;<br \/>\n    }<br \/>\n    std::string Translate(std::string word)<br \/>\n    {<br \/>\n        auto iter &#061; _dict.find(word);<br \/>\n        if(iter !&#061; _dict.end())<br \/>\n        {<br \/>\n            return iter-&gt;second;<br \/>\n        }<br \/>\n        else<br \/>\n        {<br \/>\n            return &#034;None&#034;;<br \/>\n        }<br \/>\n    }<\/p>\n<p>private:<br \/>\n    std::string _dict_path;<br \/>\n    std::unordered_map&lt;std::string, std::string&gt; _dict;<br \/>\n};<\/p>\n<p>class Dict<br \/>\n{<br \/>\npublic:<br \/>\n    Dict(const std::string &amp;dict_path &#061; default_dict)<br \/>\n    : _dict_path(dict_path)<br \/>\n    {<br \/>\n        LoadDict();<br \/>\n    }<\/p>\n<p>    void LoadDict()<br \/>\n    {<\/p>\n<p>    }<\/p>\n<p>    std::string Translate(std::string word)<br \/>\n    {<\/p>\n<p>    }<br \/>\nprivate:<br \/>\n    std::string _dict_path;<br \/>\n    std::unordered_map&lt;std::string, std::string&gt; _dict;<br \/>\n};<\/p>\n<p>EchoClient.cc \u5ba2\u6237\u7aef:<\/p>\n<p>#include &lt;iostream&gt;<br \/>\n#include &lt;string&gt;<br \/>\n#include &lt;cstring&gt;<br \/>\n#include &lt;cstdlib&gt;<br \/>\n#include &lt;sys\/socket.h&gt;<br \/>\n#include &lt;arpa\/inet.h&gt;<br \/>\n#include &lt;netinet\/in.h&gt;<\/p>\n<p>static void Usage(const std::string &amp;proc)<br \/>\n{<br \/>\n    std::cout &lt;&lt; &#034;Usage:\\\\n\\\\t&#034;;<br \/>\n    std::cout &lt;&lt; proc &lt;&lt; &#034; server_ip server_port&#034; &lt;&lt; std::endl;<br \/>\n}<\/p>\n<p>\/\/ \u6211\u600e\u4e48\u77e5\u9053server\u5bf9\u65b9\u7684IP\u548c\u7aef\u53e3\u554a&#xff0c; \u7c7b\u4f3cIP&#043;Port \u662f\u88ab\u5185\u7f6e\u5230client\u7684&#xff01;&#xff01;&#xff01;<br \/>\n\/\/ .\/client_udp server_ip server_port<br \/>\nint main(int argc, char *argv[])<br \/>\n{<br \/>\n    if(argc !&#061; 3)<br \/>\n    {<br \/>\n        Usage(argv[0]);<br \/>\n        exit(1);<br \/>\n    }<br \/>\n    std::string server_ip &#061; argv[1];<br \/>\n    uint16_t server_port &#061; std::stoi(argv[2]);<\/p>\n<p>    \/\/ 1. \u521b\u5efasocket<br \/>\n    int sockfd &#061; socket(AF_INET, SOCK_DGRAM, 0);<br \/>\n    if(sockfd &lt; 0)<br \/>\n    {<br \/>\n        std::cerr &lt;&lt; &#034;socket error&#034; &lt;&lt; std::endl;<br \/>\n        exit(2);<br \/>\n    }<\/p>\n<p>    \/\/ 2. \u6784\u5efaserver\u7aefsocket\u4fe1\u606f<br \/>\n    \/\/ client \u9700\u8981\u6709\u81ea\u5df1\u7684IP\u548cPort\u4fe1\u606f\u5417? \u9700\u8981\u7684&#xff01;<br \/>\n    \/\/ \u9700\u8981\u663e\u793a\u7684bind\u81ea\u5df1\u7684ip\u548c\u7aef\u53e3\u5417&#xff1f;\u4e0d\u8981\u663e\u793abind&#xff01;&#xff01;&#xff01;<br \/>\n    \/\/ 1. \u4e3a\u4ec0\u4e48\u4e0d\u8ba9client\u663e\u793abind&#xff1f;client bind port \u51fa\u73b0\u51b2\u7a81&#xff01;client port\u53ea\u9700\u8981\u5177\u6709\u552f\u4e00\u6027\u5373\u53ef&#xff0c;\u5177\u4f53\u662f\u51e0&#xff0c;\u4e0d\u91cd\u8981\u3002<br \/>\n    \/\/ 2. \u5982\u4f55\u8bbe\u7f6e\u81ea\u5df1\u7684IP\u548c\u7aef\u53e3\u5462&#xff1f;client \u4e00\u822c\u4f1a\u91c7\u7528\u968f\u673a\u7aef\u53e3\u7684\u65b9\u5f0f&#xff01;\u7531OS\u81ea\u4e3b\u9009\u62e9&#xff01;<br \/>\n    \/\/ udp client \u9996\u6b21\u53d1\u9001\u6570\u636e\u7684\u65f6\u5019&#xff0c;OS\u5e95\u5c42\u4f1a\u9690\u5f0f\u81ea\u52a8\u5e2e\u4f60\u8fdb\u884c\u83b7\u53d6\u968f\u673a\u7aef\u53e3&#xff0c;\u7136\u540ebind &#043; Port &#043; IP<br \/>\n    struct sockaddr_in server;<br \/>\n    memset(&amp;server, 0, sizeof(0));<br \/>\n    server.sin_family &#061; AF_INET;<br \/>\n    server.sin_port &#061; htons(server_port);<br \/>\n    server.sin_addr.s_addr &#061; inet_addr(server_ip.c_str());<\/p>\n<p>    while(true)<br \/>\n    {<br \/>\n        std::string message;<br \/>\n        \/\/ 1. \u83b7\u53d6\u7528\u6237\u8f93\u5165<br \/>\n        std::cout &lt;&lt; &#034;Please Enter# &#034;;<br \/>\n        std::getline(std::cin, message);<\/p>\n<p>        \/\/ 2. clinet \u53d1\u9001\u6570\u636e\u7ed9 server&#xff0c;\u9996\u6b21\u53d1\u9001\u5373\u81ea\u52a8bind<br \/>\n        ssize_t n &#061; sendto(sockfd, message.c_str(), message.size(), 0, (struct sockaddr*)&amp;server, sizeof(server));<br \/>\n        if(n &gt; 0)<br \/>\n        {<br \/>\n            \/\/ recvfrom<br \/>\n            char inbuffer[1024] &#061; {0};<br \/>\n            struct sockaddr_in temp;<br \/>\n            socklen_t len &#061; sizeof(temp);<br \/>\n            ssize_t m &#061; recvfrom(sockfd, inbuffer, sizeof(inbuffer)-1, 0, (struct sockaddr*)&amp;temp, &amp;len);<br \/>\n            if(m &gt; 0)<br \/>\n            {<br \/>\n                inbuffer[m] &#061; 0;<br \/>\n                std::cout &lt;&lt; inbuffer &lt;&lt; std::endl;<br \/>\n            }<br \/>\n        }<br \/>\n    }<\/p>\n<p>    return 0;<br \/>\n} <\/p>\n<p>EchoServer.hpp \u670d\u52a1\u7aef:<\/p>\n<p>#ifndef __ECHOSERVER_HPP<br \/>\n#define __ECHOSERVER_HPP<\/p>\n<p>#include &lt;iostream&gt;<br \/>\n#include &lt;string&gt;<br \/>\n#include &lt;cstdlib&gt;<br \/>\n#include &lt;strings.h&gt;<br \/>\n#include &lt;sys\/socket.h&gt;<br \/>\n#include &lt;netinet\/in.h&gt;<br \/>\n#include &lt;functional&gt;<br \/>\n#include &lt;arpa\/inet.h&gt;<\/p>\n<p>#include &#034;Logger.hpp&#034;<\/p>\n<p>using namespace NS_LOG_MODULE;<\/p>\n<p>const static int default_fd &#061; -1;<br \/>\nconst static int default_port &#061; 8888;<\/p>\n<p>using callback_t &#061; std::function&lt;std::string(std::string)&gt;;<\/p>\n<p>enum<br \/>\n{<br \/>\n    SUCCESS &#061; 0,<br \/>\n    USAGE_ERR,<br \/>\n    SOCKET_ERR,<br \/>\n    BIND_ERR,<br \/>\n};<\/p>\n<p>class UdpServer<br \/>\n{<br \/>\npublic:<br \/>\n    \/\/ UdpServer(const std::string &amp;ip, uint16_t port &#061; default_port)<br \/>\n    UdpServer(callback_t cb, uint16_t port &#061; default_port)<br \/>\n        : _port(port),<br \/>\n          _sockfd(default_fd),<br \/>\n          _cb(cb)<br \/>\n    {<br \/>\n    }<br \/>\n    ~UdpServer()<br \/>\n    {<br \/>\n        close(_sockfd);<br \/>\n    }<br \/>\n    void Init()<br \/>\n    {<br \/>\n        \/\/ \u7b2c\u4e00\u6b65: \u521b\u5efasocket, \u672c\u8d28: \u6253\u5f00\u7f51\u5361 &#8212; \u7cfb\u7edf\u7279\u6027<br \/>\n        _sockfd &#061; socket(AF_INET, SOCK_DGRAM, 0);<br \/>\n        if (_sockfd &lt; 0)<br \/>\n        {<br \/>\n            LOG(LogLevel::FATAL) &lt;&lt; &#034;create socket error&#034;;<br \/>\n            exit(SOCKET_ERR);<br \/>\n        }<br \/>\n        LOG(LogLevel::INFO) &lt;&lt; &#034;create socket success, sockfd: &#034; &lt;&lt; _sockfd;<\/p>\n<p>        \/\/ \u7b2c\u4e8c\u6b65: \u586b\u5145\u7f51\u7edc\u4fe1\u606f, \u6709\u6ca1\u6709IP\u548c\u7aef\u53e3\u4fe1\u606f\u8bbe\u7f6e\u5230\u5185\u6838\u4e2d&#xff1f;&#xff1f;\u8bbe\u7f6e\u5230\u4f60\u521a\u521a\u6253\u5f00\u7684\u7f51\u7edcsocket\u5bf9\u5e94\u7684\u6587\u4ef6\u5185\u90e8&#xff1f;<br \/>\n        struct sockaddr_in local; \/\/ struct sockaddr_in \u6570\u636e\u7c7b\u578b&#xff0c;local \u7528\u6237\u6808\u4e0a\u7684&#xff01;&#xff01;&#xff01;&#xff0c;\u5e76\u6ca1\u6709\u8bbe\u7f6e\u5230\u5185\u6838<br \/>\n        bzero(&amp;local, sizeof(local));<br \/>\n        local.sin_family &#061; AF_INET;<br \/>\n        local.sin_port &#061; htons(_port);                  \/\/ h-&gt;n<br \/>\n        \/\/ local.sin_addr.s_addr &#061; inet_addr(_ip.c_str()); \/\/ 1. \u5b57\u7b26\u4e32ip-&gt;4\u5b57\u8282IP 2. hton<br \/>\n        local.sin_addr.s_addr &#061; INADDR_ANY; \/\/ \u6700\u4f73\u5b9e\u8df5&#xff1a;\u4efb\u610fIP\u5730\u5740bind<\/p>\n<p>        \/\/ \u7b2c\u4e09\u6b65&#xff1a;bind socket \u4fe1\u606f<br \/>\n        int n &#061; bind(_sockfd, (struct sockaddr *)&amp;local, sizeof(local));<br \/>\n        if (n &lt; 0)<br \/>\n        {<br \/>\n            LOG(LogLevel::FATAL) &lt;&lt; &#034;bind socket error&#034;;<br \/>\n            exit(BIND_ERR);<br \/>\n        }<br \/>\n        LOG(LogLevel::INFO) &lt;&lt; &#034;bind socket success&#034;&lt;&lt; &#034;, port: &#034; &lt;&lt; _port;<br \/>\n    }<br \/>\n    void Start()<br \/>\n    {<br \/>\n        \/\/ \u4f20\u9012\u7684\u662f\u5b57\u7b26\u4e32,echo server<br \/>\n        char inbuffer[1024];<br \/>\n        while (true)<br \/>\n        {<br \/>\n            struct sockaddr_in peer;<br \/>\n            socklen_t len &#061; sizeof(peer);<br \/>\n            \/\/ 1. \u7528\u6237\u53d1\u6765\u7684\u6570\u636e<br \/>\n            \/\/ 2. \u7528\u6237\u7684socket\u4fe1\u606f<br \/>\n            ssize_t n &#061; recvfrom(_sockfd, inbuffer, sizeof(inbuffer) &#8211; 1, 0, (struct sockaddr *)&amp;peer, &amp;len);<br \/>\n            if (n &gt; 0)<br \/>\n            {<br \/>\n                \/\/ ?<br \/>\n                \/\/ \u7528\u6237\u7684IP &#043; Port\u4fe1\u606f,\u662frecvfrom\u4ece\u7f51\u7edc\u4e2d\u83b7\u53d6\u5230\u7684\u6570\u636e&#xff0c;\u7f51\u7edc\u5e8f\u5217&#xff08;\u5927\u7aef&#xff09;-&gt; \u8f6c\u6362\u6210\u4e3a\u4e3b\u673a\u5e8f\u5217<br \/>\n                \/\/ peer.sin_port; \/\/ peer client port<br \/>\n                \/\/ peer.sin_addr; \/\/ peer client ip<br \/>\n                \/\/ uint16_t client_port &#061; ntohs(peer.sin_port);<br \/>\n                \/\/ std::string client_ip &#061; inet_ntoa(peer.sin_addr); \/\/ 4\u5b57\u8282IP-&gt; ntoh -&gt; \u5b57\u7b26\u4e32<br \/>\n                \/\/ std::string client_address &#061; &#034;[&#034; &#043; client_ip &#043; &#034;:&#034; &#043; std::to_string(client_port) &#043; &#034;]# &#034;;<\/p>\n<p>                \/\/ \u7528\u6237\u53d1\u6765\u7684\u6570\u636e<br \/>\n                inbuffer[n] &#061; 0;<br \/>\n                \/\/ LOG(LogLevel::DEBUG) &lt;&lt; client_address &lt;&lt; inbuffer;<br \/>\n                \/\/ std::string echo_string &#061; &#034;server echo# &#034;;<br \/>\n                \/\/ echo_string &#043;&#061; inbuffer;<br \/>\n                std::string result &#061; _cb(inbuffer); \/\/ \u5355\u8bcd<\/p>\n<p>                \/\/ h to n<br \/>\n                sendto(_sockfd, result.c_str(), result.size(), 0, (struct sockaddr *)&amp;peer, len);<br \/>\n            }<br \/>\n            else<br \/>\n            {<br \/>\n                LOG(LogLevel::ERROR) &lt;&lt; &#034;recvfrom error&#034;;<br \/>\n            }<br \/>\n        }<br \/>\n    }<\/p>\n<p>private:<br \/>\n    int _sockfd;<br \/>\n    \/\/ std::string _ip; \/\/ &#034;192.168.2.2&#034;(\u5b57\u7b26\u4e32\u98ce\u683c\u7684\u70b9\u5206\u5341\u8fdb\u5236IP\u5730\u5740, \u8ba9\u4eba\u770b\u7684) &amp;&amp; 4\u5b57\u8282IP ???<br \/>\n    uint16_t _port;  \/\/ \u7528\u6237\u8bbe\u7f6e\u597d\u7684&#xff0c;server port\u5fc5\u987b\u662f\u56fa\u5b9a\u7684&#xff01;<br \/>\n    callback_t _cb; \/\/ \u7528\u56de\u8c03\u7684\u65b9\u5f0f\u8fdb\u884c\u6570\u636e\u52a0\u5de5<br \/>\n};<\/p>\n<p>#endif <\/p>\n<p>EchoServerMain.cc \u670d\u52a1\u7aef:<\/p>\n<p>#include &#034;Dict.hpp&#034;<br \/>\n#include &#034;EchoServer.hpp&#034;<br \/>\n#include &lt;memory&gt;<\/p>\n<p>static void Usage(const std::string &amp;process)<br \/>\n{<br \/>\n    std::cerr &lt;&lt; &#034;Usage:\\\\n\\\\t&#034;;<br \/>\n    std::cerr &lt;&lt; process &lt;&lt; &#034; local_port&#034; &lt;&lt; std::endl;<br \/>\n}<\/p>\n<p>\/\/ .\/server_udp port<br \/>\nint main(int argc, char *argv[])<br \/>\n{<br \/>\n    if(argc !&#061; 2)<br \/>\n    {<br \/>\n        Usage(argv[0]);<br \/>\n        exit(USAGE_ERR);<br \/>\n    }<br \/>\n    ENABLE_CONSOLE_LOG_STRATEGY();<br \/>\n    \/\/ 1. \u5b9a\u4e49\u5b57\u5178<br \/>\n    Dict dict;<br \/>\n    \/\/ 2. \u6784\u5efa\u7f51\u7edc\u670d\u52a1&#xff0c;\u5904\u7406IO\u95ee\u9898<br \/>\n    uint16_t server_port &#061; std::stoi(argv[1]);<br \/>\n    \/\/ 3. \u7ed1\u5b9a\u4e0a\u4e0b\u4e24\u5c42<br \/>\n    std::unique_ptr&lt;UdpServer&gt; usvr &#061; std::make_unique&lt;UdpServer&gt;([&amp;dict](std::string word)-&gt;std::string{<br \/>\n        return dict.Translate(word);<br \/>\n    },<br \/>\n    server_port);<br \/>\n    usvr-&gt;Init();<br \/>\n    usvr-&gt;Start();<\/p>\n<p>    return 0;<br \/>\n} <\/p>\n<p>Logger.hpp:<\/p>\n<p>#ifndef __LOGGER_HPP<br \/>\n#define __LOGGER_HPP<\/p>\n<p>#include &lt;iostream&gt;<br \/>\n#include &lt;cstdio&gt;<br \/>\n#include &lt;string&gt;<br \/>\n#include &lt;memory&gt;<br \/>\n#include &lt;sstream&gt;<br \/>\n#include &lt;ctime&gt;<br \/>\n#include &lt;sys\/time.h&gt;<br \/>\n#include &lt;unistd.h&gt;<br \/>\n#include &lt;filesystem&gt; \/\/ C&#043;&#043;17<br \/>\n#include &lt;fstream&gt;<br \/>\n#include &#034;Mutex.hpp&#034;<\/p>\n<p>namespace NS_LOG_MODULE<br \/>\n{<br \/>\n    enum class LogLevel<br \/>\n    {<br \/>\n        INFO,<br \/>\n        WARNING,<br \/>\n        ERROR,<br \/>\n        FATAL,<br \/>\n        DEBUG<br \/>\n    };<br \/>\n    std::string LogLevel2Message(LogLevel level)<br \/>\n    {<br \/>\n        switch (level)<br \/>\n        {<br \/>\n        case LogLevel::INFO:<br \/>\n            return &#034;INFO&#034;;<br \/>\n        case LogLevel::WARNING:<br \/>\n            return &#034;WARNING&#034;;<br \/>\n        case LogLevel::ERROR:<br \/>\n            return &#034;ERROR&#034;;<br \/>\n        case LogLevel::FATAL:<br \/>\n            return &#034;FATAL&#034;;<br \/>\n        case LogLevel::DEBUG:<br \/>\n            return &#034;DEBUG&#034;;<br \/>\n        default:<br \/>\n            return &#034;UNKNOWN&#034;;<br \/>\n        }<br \/>\n    }<\/p>\n<p>    \/\/ 1. \u65f6\u95f4\u6233 2. \u65e5\u671f&#043;\u65f6\u95f4<br \/>\n    std::string GetCurrentTime()<br \/>\n    {<br \/>\n        struct timeval current_time;<br \/>\n        int n &#061; gettimeofday(&amp;current_time, nullptr);<br \/>\n        (void)n;<\/p>\n<p>        \/\/ current_time.tv_sec; current_time.tv_usec;<br \/>\n        struct tm struct_time;<br \/>\n        localtime_r(&amp;(current_time.tv_sec), &amp;struct_time); \/\/ r: \u53ef\u91cd\u5165\u51fd\u6570<br \/>\n        char timestr[128];<br \/>\n        snprintf(timestr, sizeof(timestr), &#034;%04d-%02d-%02d %02d:%02d:%02d.%ld&#034;,<br \/>\n                 struct_time.tm_year &#043; 1900,<br \/>\n                 struct_time.tm_mon &#043; 1,<br \/>\n                 struct_time.tm_mday,<br \/>\n                 struct_time.tm_hour,<br \/>\n                 struct_time.tm_min,<br \/>\n                 struct_time.tm_sec,<br \/>\n                 current_time.tv_usec);<br \/>\n        return timestr;<br \/>\n    }<\/p>\n<p>    \/\/ \u8f93\u51fa\u89d2\u5ea6 &#8212; \u5237\u65b0\u7b56\u7565<br \/>\n    \/\/ 1. \u663e\u793a\u5668\u6253\u5370<br \/>\n    \/\/ 2. \u6587\u4ef6\u5199\u5165<br \/>\n    \/\/ \u7b56\u7565\u6a21\u5f0f&#xff0c;\u7b56\u7565\u63a5\u53e3<br \/>\n    class LogStrategy<br \/>\n    {<br \/>\n    public:<br \/>\n        virtual ~LogStrategy() &#061; default;<br \/>\n        virtual void SyncLog(const std::string &amp;message) &#061; 0;<br \/>\n    };<br \/>\n    \/\/ \u63a7\u5236\u53f0\u65e5\u5fd7\u5237\u65b0\u7b56\u7565, \u65e5\u5fd7\u5c06\u6765\u8981\u5411\u663e\u793a\u5668\u6253\u5370<br \/>\n    class ConsoleStrategy : public LogStrategy<br \/>\n    {<br \/>\n    public:<br \/>\n        void SyncLog(const std::string &amp;message) override<br \/>\n        {<br \/>\n            LockGuard lockguard(_mutex);<br \/>\n            std::cerr &lt;&lt; message &lt;&lt; std::endl; \/\/ ??<br \/>\n        }<br \/>\n        ~ConsoleStrategy()<br \/>\n        {<br \/>\n        }<\/p>\n<p>    private:<br \/>\n        Mutex _mutex;<br \/>\n    };<\/p>\n<p>    const std::string defaultpath &#061; &#034;.\/log&#034;;<br \/>\n    const std::string defaultfilename &#061; &#034;log.txt&#034;;<\/p>\n<p>    \/\/ \u6587\u4ef6\u7b56\u7565<br \/>\n    class FileLogStrategy : public LogStrategy<br \/>\n    {<br \/>\n    public:<br \/>\n        FileLogStrategy(const std::string &amp;path &#061; defaultpath, const std::string &amp;name &#061; defaultfilename)<br \/>\n            : _logpath(path),<br \/>\n              _logfilename(name)<br \/>\n        {<br \/>\n            LockGuard lockguard(_mutex);<br \/>\n            if (std::filesystem::exists(_logpath))<br \/>\n                return;<br \/>\n            try<br \/>\n            {<br \/>\n                std::filesystem::create_directories(_logpath);<br \/>\n            }<br \/>\n            catch (const std::filesystem::filesystem_error &amp;e)<br \/>\n            {<br \/>\n                std::cerr &lt;&lt; e.what() &lt;&lt; &#039;\\\\n&#039;;<br \/>\n            }<br \/>\n        }<\/p>\n<p>        void SyncLog(const std::string &amp;message) override<br \/>\n        {<br \/>\n            {<br \/>\n                LockGuard lockguard(_mutex);<br \/>\n                if (!_logpath.empty() &amp;&amp; _logpath.back() !&#061; &#039;\/&#039;)<br \/>\n                {<br \/>\n                    _logpath &#043;&#061; &#034;\/&#034;;<br \/>\n                }<br \/>\n                std::string targetlog &#061; _logpath &#043; _logfilename; \/\/ &#034;.\/log\/log.txt&#034;<br \/>\n                std::ofstream out(targetlog, std::ios::app);     \/\/ \u8ffd\u52a0\u65b9\u5f0f\u5199\u5165<br \/>\n                if (!out.is_open())<br \/>\n                {<br \/>\n                    std::cerr &lt;&lt; &#034;open &#034; &lt;&lt; targetlog &lt;&lt; &#034;failed&#034; &lt;&lt; std::endl;<br \/>\n                    return;<br \/>\n                }<br \/>\n                out &lt;&lt; message &lt;&lt; &#034;\\\\n&#034;;<br \/>\n                out.close();<br \/>\n            }<br \/>\n        }<\/p>\n<p>        ~FileLogStrategy()<br \/>\n        {<br \/>\n        }<\/p>\n<p>    private:<br \/>\n        std::string _logpath;<br \/>\n        std::string _logfilename;<br \/>\n        Mutex _mutex;<br \/>\n    };<\/p>\n<p>    \/\/ \u65e5\u5fd7\u7c7b:<br \/>\n    \/\/ 1. \u65e5\u5fd7\u7684\u751f\u6210<br \/>\n    \/\/ 2. \u6839\u636e\u4e0d\u540c\u7684\u7b56\u7565&#xff0c;\u8fdb\u884c\u5237\u65b0<br \/>\n    class Logger<br \/>\n    {<br \/>\n        \/\/ \u65e5\u5fd7\u7684\u751f\u6210:<br \/>\n        \/\/ \u6784\u5efa\u65e5\u5fd7\u5b57\u7b26\u4e32<br \/>\n    public:<br \/>\n        Logger()<br \/>\n        {<br \/>\n            UseConsoleStrategy();<br \/>\n        }<br \/>\n        void UseConsoleStrategy()<br \/>\n        {<br \/>\n            _strategy &#061; std::make_unique&lt;ConsoleStrategy&gt;();<br \/>\n        }<br \/>\n        void UseFileStrategy()<br \/>\n        {<br \/>\n            _strategy &#061; std::make_unique&lt;FileLogStrategy&gt;();<br \/>\n        }<br \/>\n        \/\/ \u5185\u90e8\u7c7b, \u6807\u8bc6\u4e00\u6761\u5b8c\u6574\u7684\u65e5\u5fd7\u4fe1\u606f<br \/>\n        \/\/  \u4e00\u6761\u5b8c\u6574\u7684\u65e5\u5fd7\u4fe1\u606f &#061; \u505a\u534a\u90e8\u5206\u56fa\u5b9a\u90e8\u5206 &#043; \u53f3\u534a\u90e8\u5206\u4e0d\u56fa\u5b9a\u90e8\u5206<br \/>\n        \/\/  LogMessage RAII\u98ce\u683c\u7684\u65b9\u5f0f&#xff0c;\u8fdb\u884c\u5237\u65b0<br \/>\n        class LogMessage<br \/>\n        {<br \/>\n        public:<br \/>\n            LogMessage(LogLevel level, std::string &amp;filename, int line, Logger &amp;logger)<br \/>\n                : _level(level),<br \/>\n                  _curr_time(GetCurrentTime()),<br \/>\n                  _pid(getpid()),<br \/>\n                  _filename(filename),<br \/>\n                  _line(line),<br \/>\n                  _logger(logger)<br \/>\n            {<br \/>\n                \/\/ \u5148\u6784\u5efa\u51fa\u6765\u5de6\u534a\u90e8\u5206<br \/>\n                std::stringstream ss;<br \/>\n                ss &lt;&lt; &#034;[&#034; &lt;&lt; _curr_time &lt;&lt; &#034;] &#034;<br \/>\n                   &lt;&lt; &#034;[&#034; &lt;&lt; LogLevel2Message(_level) &lt;&lt; &#034;] &#034;<br \/>\n                   &lt;&lt; &#034;[&#034; &lt;&lt; _pid &lt;&lt; &#034;] &#034;<br \/>\n                   &lt;&lt; &#034;[&#034; &lt;&lt; _filename &lt;&lt; &#034;] &#034;<br \/>\n                   &lt;&lt; &#034;[&#034; &lt;&lt; _line &lt;&lt; &#034;] &#034;<br \/>\n                   &lt;&lt; &#034; &#8211; &#034;;<\/p>\n<p>                _loginfo &#061; ss.str();<br \/>\n            }<br \/>\n            template &lt;typename T&gt;<br \/>\n            LogMessage &amp;operator&lt;&lt;(const T &amp;info)<br \/>\n            {<br \/>\n                std::stringstream ss;<br \/>\n                ss &lt;&lt; info;<br \/>\n                _loginfo &#043;&#061; ss.str();<br \/>\n                return *this; \/\/ \u8fd4\u56de\u5f53\u524dLogMessage\u5bf9\u8c61&#xff0c;\u65b9\u4fbf\u4e0b\u6b21\u7ee7\u7eed\u8fdb\u884c&lt;&lt;<br \/>\n            }<\/p>\n<p>            ~LogMessage()<br \/>\n            {<br \/>\n                if (_logger._strategy)<br \/>\n                {<br \/>\n                    _logger._strategy-&gt;SyncLog(_loginfo);<br \/>\n                }<br \/>\n            }<\/p>\n<p>        private:<br \/>\n            LogLevel _level;<br \/>\n            std::string _curr_time;<br \/>\n            pid_t _pid;<br \/>\n            std::string _filename;<br \/>\n            int _line;<br \/>\n            std::string _loginfo; \/\/ \u4e00\u6761\u5b8c\u6574\u7684\u65e5\u5fd7\u4fe1\u606f<\/p>\n<p>            \/\/ \u4e00\u4e2a\u5f15\u7528&#xff0c;\u5f15\u7528\u5916\u90e8\u7684Logger\u7c7b\u5bf9\u8c61<br \/>\n            Logger &amp;_logger; \/\/ \u65b9\u4fbf\u6211\u4eec\u540e\u7eed\u8fdb\u884c\u7b56\u7565\u5f0f\u5237\u65b0<br \/>\n        };<\/p>\n<p>        \/\/ \u8fd9\u91cc\u5df2\u7ecf\u4e0d\u662f\u5185\u90e8\u7c7b\u4e86<br \/>\n        \/\/ \u6545\u610f\u91c7\u7528\u62f7\u8d1dLogMessage<br \/>\n        LogMessage operator()(LogLevel level, std::string filename, int line)<br \/>\n        {<br \/>\n            return LogMessage(level, filename, line, *this);<br \/>\n        }<\/p>\n<p>        ~Logger()<br \/>\n        {<br \/>\n        }<\/p>\n<p>    private:<br \/>\n        std::unique_ptr&lt;LogStrategy&gt; _strategy; \/\/ \u5237\u65b0\u7b56\u7565<br \/>\n    };<\/p>\n<p>    \/\/ \u65e5\u5fd7\u5bf9\u8c61&#xff0c;\u5168\u5c40\u4f7f\u7528<br \/>\n    Logger logger;<\/p>\n<p>#define ENABLE_CONSOLE_LOG_STRATEGY() logger.UseConsoleStrategy();<br \/>\n#define ENABLE_FILE_LOG_STRATEGY() logger.UseFileStrategy();<\/p>\n<p>#define LOG(level) logger(level, __FILE__, __LINE__)<\/p>\n<p>}<\/p>\n<p>#endif<\/p>\n<p>Makefile:<\/p>\n<p>.PHONY:all<br \/>\nall:client_udp server_udp<\/p>\n<p>server_udp:EchoServerMain.cc<br \/>\ng&#043;&#043; -o $&#064; $^ -std&#061;c&#043;&#043;17<br \/>\nclient_udp:EchoClient.cc<br \/>\ng&#043;&#043; -o $&#064; $^ -std&#061;c&#043;&#043;17 -static<\/p>\n<p>.PHONY:clean<br \/>\nclean:<br \/>\nrm -f client_udp server_udp <\/p>\n<p>Mutex.hpp<\/p>\n<p>#pragma once<\/p>\n<p>#include &lt;iostream&gt;<br \/>\n#include &lt;pthread.h&gt;<\/p>\n<p>class Mutex<br \/>\n{<br \/>\npublic:<br \/>\n    Mutex()<br \/>\n    {<br \/>\n        pthread_mutex_init(&amp;_lock, nullptr);<br \/>\n    }<br \/>\n    void Lock()<br \/>\n    {<br \/>\n        pthread_mutex_lock(&amp;_lock);<br \/>\n    }<br \/>\n    pthread_mutex_t *Ptr()<br \/>\n    {<br \/>\n        return &amp;_lock;<br \/>\n    }<br \/>\n    void Unlock()<br \/>\n    {<br \/>\n        pthread_mutex_unlock(&amp;_lock);<br \/>\n    }<br \/>\n    ~Mutex()<br \/>\n    {<br \/>\n        pthread_mutex_destroy(&amp;_lock);<br \/>\n    }<br \/>\nprivate:<br \/>\n    pthread_mutex_t _lock;<br \/>\n};<\/p>\n<p>class LockGuard \/\/ RAII\u98ce\u683c\u4ee3\u7801<br \/>\n{<br \/>\npublic:<br \/>\n    LockGuard(Mutex &amp;lock):_lockref(lock)<br \/>\n    {<br \/>\n        _lockref.Lock();<br \/>\n    }<br \/>\n    ~LockGuard()<br \/>\n    {<br \/>\n        _lockref.Unlock();<br \/>\n    }<br \/>\nprivate:<br \/>\n    Mutex &amp;_lockref;<br \/>\n}; <\/p>\n<p>dict.txt:<\/p>\n<p>apple: \u82f9\u679c<br \/>\nbanana: \u9999\u8549<br \/>\ncat: \u732b<br \/>\ndog: \u72d7<br \/>\nbook: \u4e66<br \/>\npen: \u7b14<br \/>\nhappy: \u5feb\u4e50\u7684<br \/>\nsad: \u60b2\u4f24\u7684<br \/>\nrun: \u8dd1<br \/>\njump: \u8df3<br \/>\nteacher: \u8001\u5e08<br \/>\nstudent: \u5b66\u751f<br \/>\ncar: \u6c7d\u8f66<br \/>\nbus: \u516c\u4ea4\u8f66<br \/>\nlove: \u7231<br \/>\nhate: \u6068<br \/>\nhello: \u4f60\u597d<br \/>\ngoodbye: \u518d\u89c1<br \/>\nsummer: \u590f\u5929<br \/>\nwinter: \u51ac\u5929<br \/>\nfall: \u79cb\u5929<br \/>\nLiz: \u6817\u5b50 <\/p>\n<h2 id=\"%E4%B8%89%E3%80%81%E6%80%BB%E7%BB%93\">\u4e09\u3001\u603b\u7ed3<\/h2>\n<p>\u672c\u6587\u9a8c\u8bc1\u4e86Windows\u4e0eLinux\u7cfb\u7edf\u95f4\u57fa\u4e8eUDP\u534f\u8bae\u7684\u7f51\u7edc\u901a\u4fe1\u53ef\u884c\u6027&#xff0c;\u5e76\u5b9e\u73b0\u4e86\u5b57\u5178\u7ffb\u8bd1\u529f\u80fd\u7684\u670d\u52a1\u7aef\u5206\u5c42\u67b6\u6784\u6539\u9020\u3002\u4e3b\u8981\u5185\u5bb9\u5305\u62ec&#xff1a;<\/p>\n<li>\n<p>\u8de8\u5e73\u53f0\u901a\u4fe1\u9a8c\u8bc1&#xff1a;Windows\u5ba2\u6237\u7aef\u901a\u8fc7VS2022\u5f00\u53d1&#xff0c;\u8c03\u7528\u6807\u51c6Socket\u63a5\u53e3\u4e0eLinux\u670d\u52a1\u7aef\u6210\u529f\u5b9e\u73b0UDP\u901a\u4fe1&#xff0c;\u8bc1\u660e\u4e0d\u540c\u64cd\u4f5c\u7cfb\u7edf\u95f4\u7f51\u7edc\u4e92\u901a\u7684\u53ef\u884c\u6027\u3002<\/p>\n<\/li>\n<li>\n<p>\u670d\u52a1\u7aef\u67b6\u6784\u5347\u7ea7&#xff1a;<\/p>\n<\/li>\n<ul>\n<li>\u5c06\u539f\u6709\u56de\u58f0\u670d\u52a1\u6539\u9020\u4e3a\u4e24\u5c42\u67b6\u6784&#xff1a;\u5e95\u5c42\u7f51\u7edcIO\u6a21\u5757\u8d1f\u8d23\u6570\u636e\u4f20\u8f93&#xff0c;\u4e0a\u5c42Dict\u6a21\u5757\u4e13\u6ce8\u4e1a\u52a1\u903b\u8f91<\/li>\n<li>\u901a\u8fc7\u56de\u8c03\u673a\u5236\u5b9e\u73b0\u89e3\u8026&#xff0c;\u7f51\u7edc\u5c42\u8c03\u7528\u6ce8\u5165\u7684\u7ffb\u8bd1\u51fd\u6570\u5904\u7406\u6570\u636e<\/li>\n<li>\u65b0\u589eDict\u7c7b\u5b9e\u73b0\u5b57\u5178\u52a0\u8f7d\u548c\u5355\u8bcd\u7ffb\u8bd1\u529f\u80fd<\/li>\n<\/ul>\n<li>\u529f\u80fd\u5b9e\u73b0&#xff1a;<\/li>\n<ul>\n<li>\u5ba2\u6237\u7aef\u53d1\u9001\u82f1\u6587\u5355\u8bcd&#xff0c;\u670d\u52a1\u7aef\u8fd4\u56de\u4e2d\u6587\u7ffb\u8bd1<\/li>\n<li>\u91c7\u7528\u65e5\u5fd7\u6a21\u5757\u8bb0\u5f55\u8fd0\u884c\u72b6\u6001<\/li>\n<li>\u901a\u8fc7Lambda\u8868\u8fbe\u5f0f\u5b9e\u73b0\u56de\u8c03\u9002\u914d<\/li>\n<\/ul>\n<p>\u4ee3\u7801\u7ed3\u6784\u6e05\u6670\u5c55\u793a\u4e86\u7f51\u7edc\u5c42\u4e0e\u4e1a\u52a1\u5c42\u7684\u5206\u79bb&#xff0c;\u4e3a\u540e\u7eed\u529f\u80fd\u6269\u5c55\u63d0\u4f9b\u4e86\u826f\u597d\u57fa\u7840\u3002<\/p>\n<p>\u8c22\u8c22\u5927\u5bb6\u7684\u89c2\u770b!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u76ee\u5f55<br \/>\n\u4e00\u3001Windows\u4e0eLinux\u901a\u4fe1<br \/>\nWindows \u5ba2\u6237\u7aef\u73af\u5883&#xff08;VS2022&#xff09;<br \/>\nLinux \u670d\u52a1\u7aef\u73af\u5883&#xff08;Ubuntu  Xshell&#xff09;<br \/>\n\u200b\u7f16\u8f91<br \/>\n\u8fd0\u884c\u7ed3\u679c :<br \/>\n\u4e8c\u3001\u65b0\u589e\u00a0Dict \u5b57\u5178\u7ffb\u8bd1\u6a21\u5757\u7684\u00a0UDP \u901a\u4fe1<br \/>\nDict\u00a0\u7c7b<br \/>\nDict \u7c7b\u6574\u4f53\u7ed3\u6784<br \/>\nLoadDict()&#xff1a;\u4ece\u6587\u4ef6\u52a0\u8f7d\u5b57\u5178\u6570\u636e<br \/>\nTranslate()&#xff1a;\u5b9e\u73b0\u6838\u5fc3\u7ffb\u8bd1\u903b\u8f91<br \/>\nEchoServer.hpp \u6587\u4ef6\u4e2d U<\/p>\n","protected":false},"author":2,"featured_media":82976,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[58,193,43,427,78],"topic":[],"class_list":["post-82996","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-linux","tag-udp","tag-43","tag-427","tag-78"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Linux \u7f51\u7edc\u5957\u63a5\u5b57\u7f16\u7a0b\uff08\u4e09\uff09UDP\u670d\u52a1\u5668\u4e0e\u5ba2\u6237\u7aef\u5b9e\u73b0\uff1aWindows\u4e0eLinux\u901a\u4fe1\uff0c\u65b0\u589e\u5b57\u5178\u7ffb\u8bd1\u529f\u80fd\u7684 UDP \u901a\u4fe1 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/82996.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Linux \u7f51\u7edc\u5957\u63a5\u5b57\u7f16\u7a0b\uff08\u4e09\uff09UDP\u670d\u52a1\u5668\u4e0e\u5ba2\u6237\u7aef\u5b9e\u73b0\uff1aWindows\u4e0eLinux\u901a\u4fe1\uff0c\u65b0\u589e\u5b57\u5178\u7ffb\u8bd1\u529f\u80fd\u7684 UDP \u901a\u4fe1 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u76ee\u5f55 \u4e00\u3001Windows\u4e0eLinux\u901a\u4fe1 Windows \u5ba2\u6237\u7aef\u73af\u5883&#xff08;VS2022&#xff09; Linux \u670d\u52a1\u7aef\u73af\u5883&#xff08;Ubuntu Xshell&#xff09; \u200b\u7f16\u8f91 \u8fd0\u884c\u7ed3\u679c : \u4e8c\u3001\u65b0\u589e\u00a0Dict \u5b57\u5178\u7ffb\u8bd1\u6a21\u5757\u7684\u00a0UDP \u901a\u4fe1 Dict\u00a0\u7c7b Dict \u7c7b\u6574\u4f53\u7ed3\u6784 LoadDict()&#xff1a;\u4ece\u6587\u4ef6\u52a0\u8f7d\u5b57\u5178\u6570\u636e Translate()&#xff1a;\u5b9e\u73b0\u6838\u5fc3\u7ffb\u8bd1\u903b\u8f91 EchoServer.hpp \u6587\u4ef6\u4e2d U\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/82996.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-07-25T07:27:02+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/07\/20260725072655-6a64653f10724.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"12 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/82996.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/82996.html\",\"name\":\"Linux \u7f51\u7edc\u5957\u63a5\u5b57\u7f16\u7a0b\uff08\u4e09\uff09UDP\u670d\u52a1\u5668\u4e0e\u5ba2\u6237\u7aef\u5b9e\u73b0\uff1aWindows\u4e0eLinux\u901a\u4fe1\uff0c\u65b0\u589e\u5b57\u5178\u7ffb\u8bd1\u529f\u80fd\u7684 UDP \u901a\u4fe1 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-07-25T07:27:02+00:00\",\"dateModified\":\"2026-07-25T07:27:02+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/82996.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/82996.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/82996.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Linux \u7f51\u7edc\u5957\u63a5\u5b57\u7f16\u7a0b\uff08\u4e09\uff09UDP\u670d\u52a1\u5668\u4e0e\u5ba2\u6237\u7aef\u5b9e\u73b0\uff1aWindows\u4e0eLinux\u901a\u4fe1\uff0c\u65b0\u589e\u5b57\u5178\u7ffb\u8bd1\u529f\u80fd\u7684 UDP \u901a\u4fe1\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Linux \u7f51\u7edc\u5957\u63a5\u5b57\u7f16\u7a0b\uff08\u4e09\uff09UDP\u670d\u52a1\u5668\u4e0e\u5ba2\u6237\u7aef\u5b9e\u73b0\uff1aWindows\u4e0eLinux\u901a\u4fe1\uff0c\u65b0\u589e\u5b57\u5178\u7ffb\u8bd1\u529f\u80fd\u7684 UDP \u901a\u4fe1 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/82996.html","og_locale":"zh_CN","og_type":"article","og_title":"Linux \u7f51\u7edc\u5957\u63a5\u5b57\u7f16\u7a0b\uff08\u4e09\uff09UDP\u670d\u52a1\u5668\u4e0e\u5ba2\u6237\u7aef\u5b9e\u73b0\uff1aWindows\u4e0eLinux\u901a\u4fe1\uff0c\u65b0\u589e\u5b57\u5178\u7ffb\u8bd1\u529f\u80fd\u7684 UDP \u901a\u4fe1 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u76ee\u5f55 \u4e00\u3001Windows\u4e0eLinux\u901a\u4fe1 Windows \u5ba2\u6237\u7aef\u73af\u5883&#xff08;VS2022&#xff09; Linux \u670d\u52a1\u7aef\u73af\u5883&#xff08;Ubuntu Xshell&#xff09; \u200b\u7f16\u8f91 \u8fd0\u884c\u7ed3\u679c : \u4e8c\u3001\u65b0\u589e\u00a0Dict \u5b57\u5178\u7ffb\u8bd1\u6a21\u5757\u7684\u00a0UDP \u901a\u4fe1 Dict\u00a0\u7c7b Dict \u7c7b\u6574\u4f53\u7ed3\u6784 LoadDict()&#xff1a;\u4ece\u6587\u4ef6\u52a0\u8f7d\u5b57\u5178\u6570\u636e Translate()&#xff1a;\u5b9e\u73b0\u6838\u5fc3\u7ffb\u8bd1\u903b\u8f91 EchoServer.hpp \u6587\u4ef6\u4e2d U","og_url":"https:\/\/www.wsisp.com\/helps\/82996.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-07-25T07:27:02+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/07\/20260725072655-6a64653f10724.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"12 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/82996.html","url":"https:\/\/www.wsisp.com\/helps\/82996.html","name":"Linux \u7f51\u7edc\u5957\u63a5\u5b57\u7f16\u7a0b\uff08\u4e09\uff09UDP\u670d\u52a1\u5668\u4e0e\u5ba2\u6237\u7aef\u5b9e\u73b0\uff1aWindows\u4e0eLinux\u901a\u4fe1\uff0c\u65b0\u589e\u5b57\u5178\u7ffb\u8bd1\u529f\u80fd\u7684 UDP \u901a\u4fe1 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-07-25T07:27:02+00:00","dateModified":"2026-07-25T07:27:02+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/82996.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/82996.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/82996.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Linux \u7f51\u7edc\u5957\u63a5\u5b57\u7f16\u7a0b\uff08\u4e09\uff09UDP\u670d\u52a1\u5668\u4e0e\u5ba2\u6237\u7aef\u5b9e\u73b0\uff1aWindows\u4e0eLinux\u901a\u4fe1\uff0c\u65b0\u589e\u5b57\u5178\u7ffb\u8bd1\u529f\u80fd\u7684 UDP \u901a\u4fe1"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/82996","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=82996"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/82996\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/82976"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=82996"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=82996"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=82996"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=82996"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}