{"id":115877,"date":"2026-10-20T14:01:06","date_gmt":"2026-10-20T06:01:06","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/115877.html"},"modified":"2026-10-20T14:01:06","modified_gmt":"2026-10-20T06:01:06","slug":"%e4%bb%bfmuduo%e5%ae%9e%e7%8e%b0%e9%ab%98%e5%b9%b6%e5%8f%91%e6%9c%8d%e5%8a%a1%e5%99%a8-%e7%ab%af%e5%af%b9%e7%ab%afsocket-hpp","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/115877.html","title":{"rendered":"\u4effmuduo\u5b9e\u73b0\u9ad8\u5e76\u53d1\u670d\u52a1\u5668\u2014\u2014\u7aef\u5bf9\u7aefSocket.hpp"},"content":{"rendered":"<p>        \/* MD \/ \u5bcc\u6587\u672c\u4e2d\u7684 .toc\uff08\u542b\u535a\u5ba2\u56ed\u642c\u5bb6\u7b49\u5d4c\u5957\u7ed3\u6784\uff09\uff1b.toc-box \u5728\u4fa7\u680f\uff0c\u4e0d\u53d7\u5f71\u54cd *\/<br \/>\n        #content_views .toc,<br \/>\n        \/* \u7f16\u8f91\u5668\u5e38\u5728\u76ee\u5f55\u524d\u540e\u63d2\u5165\u7a7a p\uff08:empty \u4ecd\u5360 20px\uff09\uff0c\u4e00\u5e76\u53bb\u6389\u907f\u514d\u9876\u7a7a\u9699 *\/<br \/>\n        #content_views.markdown_views &gt; p:empty:has(+ .toc),<br \/>\n        #content_views.markdown_views &gt; .toc + p:empty,<br \/>\n        \/* \u5bcc\u6587\u672c\u65e7\u7248\u76ee\u5f55\u6807\u8bb0 *\/<br \/>\n        #content_views.htmledit_views #main-toc,<br \/>\n        #content_views.htmledit_views #hr-toc,<br \/>\n        #content_views.htmledit_views p[id*=\\&#8221;-toc\\&#8221;] {<br \/>\n          display: none !important;<br \/>\n        }<br \/>\n        \/* \u76ee\u5f55\u53bb\u6389\u540e\uff0c\u7d27\u8ddf\u7684\u9996\u4e2a\u6807\u9898\u4e0d\u518d\u591a\u51fa\u4e00\u5757\u4e0a\u8fb9\u8ddd *\/<br \/>\n        #content_views.markdown_views &gt; .toc + h1,<br \/>\n        #content_views.markdown_views &gt; .toc + h2,<br \/>\n        #content_views.markdown_views &gt; .toc + h3,<br \/>\n        #content_views.markdown_views &gt; .toc + h4,<br \/>\n        #content_views.markdown_views &gt; .toc + p:empty + h1,<br \/>\n        #content_views.markdown_views &gt; .toc + p:empty + h2,<br \/>\n        #content_views.markdown_views &gt; .toc + p:empty + h3,<br \/>\n        #content_views.markdown_views &gt; .toc + p:empty + h4 {<br \/>\n          margin-top: 0 !important;<br \/>\n        }<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261020060103-6ad7039f799d6.png\" alt=\"@bit::Shadow \u2727(\u2256 \u25e1 \u2256\u273f)\" width=\"300\" height=\"300\" \/> <\/p>\n<h4>\u76ee\u5f55<\/h4>\n<ul>\n<li>\n<ul>\n<li>\u6458\u8981<\/li>\n<li>\u6ce8\u91ca<\/li>\n<li>\n<ul>\n<li>3.1 \u56de\u987e<\/li>\n<li>3.2 \u65b0\u77e5\u8bc6<\/li>\n<li>3.3 \u6ce8\u610f<\/li>\n<li>3.4 \u53cd\u601d<\/li>\n<\/ul>\n<\/li>\n<li>\u6b63\u6587<\/li>\n<li>\n<ul>\n<li>4.1 \u751f\u547d\u5468\u671f\u4e0e\u8fd4\u56de\u503c\u7ea6\u5b9a<\/li>\n<li>4.2 \u670d\u52a1\u7aef\u8def\u5f84<\/li>\n<li>4.3 \u6536\u53d1\u4e0e\u963b\u585e<\/li>\n<li>4.4 \u5f00\u53d1\u4e2d\u9047\u5230\u7684\u95ee\u9898<\/li>\n<\/ul>\n<\/li>\n<li>\u603b\u7ed3<\/li>\n<li>\u5e38\u89c1\u95ee\u9898<\/li>\n<li>\u6807\u7b7e<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3>\u6458\u8981<\/h3>\n<p>Socket.hpp \u662f header-only \u7684\u5355\u53e5\u67c4 TCP \u5c01\u88c5&#xff0c;\u552f\u4e00\u6210\u5458\u4e3a int _sockfd&#xff0c;\u9ed8\u8ba4\u6784\u9020\u7f6e -1&#xff0c;\u6790\u6784 close \u540e\u590d\u4f4d\u3002\u5bf9\u5916\u63d0\u4f9b Create \/ Bind \/ Listen \/ Accept \/ Connect \/ Recv \/ Send \/ Close&#xff0c;\u53e6\u6709 SetNonBlock\u3001SetNonBlockRecv \/ SetNonBlockSend \u4e0e CreateServer \/ CreateClient \u4e24\u4e2a\u7ec4\u5408\u5165\u53e3\u3002\u4ef7\u503c\u5728\u4e8e\u628a\u7cfb\u7edf\u8c03\u7528\u8fd4\u56de\u503c\u5224\u5b9a\u3001sockaddr_in \u586b\u5145\u4e0e\u5b57\u8282\u5e8f\u8f6c\u6362\u6536\u5728\u4e00\u5904\u3002\u6ce8\u91ca\u6bb5\u81ea\u8ff0&#xff1a;\u672c\u5b9e\u73b0\u4fdd\u8bc1 HTTP \u8bf7\u6c42\u7684\u670d\u52a1\u7aef\u800c\u975e\u5ba2\u6237\u7aef\u3002<\/p>\n<p>\u4ee3\u7801\u4ed3\u5e93&#xff1a;https:\/\/gitee.com\/btshadow\/Ubuntu_learning\/blob\/master\/October\/10-17\/muduo\/src\/server.hpp<\/p>\n<h3>\u6ce8\u91ca<\/h3>\n<h4>3.1 \u56de\u987e<\/h4>\n<p>htons\/ntohs&#xff1a;TCP\/IP \u89c4\u5b9a\u7528\u5927\u7aef\u5e8f&#xff0c;\u5373\u7f51\u7edc\u5b57\u8282\u5e8f&#xff1b;\u672c\u673a\u7b97\u51fa\u8981\u53d1\u5230\u7f51\u7edc\u7528 htons\/htonl&#xff0c;\u4ece\u7f51\u7edc\u6536\u5230\u8f6c\u672c\u673a\u7528 ntohs\/ntohl\u3002Bind \u4e0e Connect \u91cc\u7684 htons(port) \u5c5e\u4e8e\u670d\u52a1\u7aef\u81ea\u8eab\u7ed1\u5b9a\u3001\u8981\u8ba9\u5ba2\u6237\u7aef\u770b\u5230\u8be5\u7aef\u53e3\u7684\u90a3\u4e00\u4fa7\u3002 accept \u4e8c\u3001\u4e09\u53c2\u6570&#xff1a;\u7b2c\u4e8c\u53c2\u6570\u662f\u8f93\u51fa\u53c2\u6570&#xff0c;\u5b58\u653e\u5bf9\u7aef\u5730\u5740&#xff1b;\u7b2c\u4e09\u53c2\u6570\u662f\u503c-\u7ed3\u679c\u53c2\u6570&#xff0c;\u4f20\u5165\u65f6\u4e3a addr \u7f13\u51b2\u533a\u5927\u5c0f&#xff0c;\u8fd4\u56de\u65f6\u4e3a\u5b9e\u9645\u5199\u5165\u957f\u5ea6&#xff08;\u89c1 bug3&#xff09;\u3002 ET \u6a21\u5f0f&#xff1a;epoll \u7684\u8fb9\u7f18\u89e6\u53d1&#xff0c;\u53ea\u6709\u72b6\u6001\u53d8\u5316&#xff08;\u4ece\u65e0\u5230\u6709\/\u4ece\u6709\u5230\u591a&#xff09;\u65f6\u901a\u77e5\u4e00\u6b21&#xff0c;\u5bf9\u6bd4 LT\u3002\u672c\u6587\u4ef6\u672a\u542b epoll&#xff0c;\u4ec5\u8bb0\u5f55\u3002<\/p>\n<h4>3.2 \u65b0\u77e5\u8bc6<\/h4>\n<p>noexcept(true) \u7b49\u4ef7\u4e8e noexcept&#xff0c;\u662f&#034;\u4e0d\u629b\u5f02\u5e38&#034;\u7684\u663e\u5f0f\u58f0\u660e&#xff1b;\u5185\u90e8\u771f\u629b\u4e86\u5f02\u5e38\u5219\u76f4\u63a5 std::terminate()\u3002\u627f\u8bfa\u7684\u662f\u4e0d\u629b C&#043;&#043; \u5f02\u5e38&#xff0c;\u4e0d\u662f\u8c03\u7528\u4e00\u5b9a\u6210\u529f\u3002\u4ef7\u503c\u5728\u4e8e\u79fb\u52a8\u6784\u9020\/\u79fb\u52a8\u8d4b\u503c\u6807 noexcept \u540e&#xff0c;std::vector \u7b49\u5bb9\u5668\u6269\u5bb9\u8d70\u79fb\u52a8\u800c\u975e\u62f7\u8d1d\u3002\u53ea\u5728\u786e\u5b9e\u4e0d\u629b\u5904\u7528&#xff08;\u79fb\u52a8\u6784\u9020\u3001swap\u3001\u6790\u6784\u3001getter&#xff09;&#xff0c;\u53ef\u80fd\u5206\u914d\u5185\u5b58\u6216\u629b\u4e1a\u52a1\u5f02\u5e38\u7684\u4e0d\u6807\u3002\u672c\u6587\u4ef6\u4e2d\u5e26 noexcept \u7684\u53ea\u6709\u6ce8\u91ca\u6284\u5f55\u7684 listen \u539f\u578b\u3002<\/p>\n<h4>3.3 \u6ce8\u610f<\/h4>\n<p>sockaddr_in \u5728 bind \u4e0e connect \u524d\u6709\u5fc5\u8981\u6e05\u7a7a&#xff08;Bind\u3001Connect \u5404\u6709 memset&#xff09;&#xff0c;accept \u65f6\u6ca1\u5fc5\u8981&#xff0c;\u56e0\u4e3a accept \u5185\u662f\u8986\u76d6\u5f0f\u5199\u5165&#xff08;Accept \u672a memset&#xff09;\u3002 EAGAIN \u4e0e EINTR \u4f5c\u4e3a\u8bfb\/\u5199\u5f02\u5e38&#xff1a;EAGAIN \u5173\u8054\u975e\u963b\u585e&#xff08;MSG_DONTWAIT&#xff09;&#xff0c;EINTR \u5173\u8054\u4fe1\u53f7&#xff0c;\u4e0e\u975e\u963b\u585e\u5173\u7cfb\u5c0f&#xff08;Recv\u3001Send \u7684 errno \u5224\u5b9a&#xff09;\u3002 \u5ba2\u6237\u7aef\u65e0\u9700 bind&#xff1a;\u5ba2\u6237\u7aef\u95f4\u5404\u81ea\u72ec\u7acb\u4e14\u96be\u4ee5\u624b\u52a8\u7ba1\u7406&#xff0c;\u5185\u6838\u5df2\u4ee3\u505a&#xff0c;\u6545 CreateClient \u53ea\u6709 Create &#043; Connect\u3002<\/p>\n<h4>3.4 \u53cd\u601d<\/h4>\n<p>\u6d4b\u8bd5\u65f6\u592a\u5927\u610f\u4e86&#xff0c;\u4e3b\u8981\u662f\u4e0d\u60f3\u6d4b\u8bd5\u3001\u60f3\u5feb\u70b9\u7ed3\u675f&#xff0c;\u7ed3\u679c\u4ee3\u7801\u672c\u8eab\u6ca1\u6709 bug&#xff0c;\u5374\u56e0\u6d4b\u8bd5\u65b9\u5f0f\u4ee5\u4e3a\u6709 bug\u3002<\/p>\n<h3>\u6b63\u6587<\/h3>\n<h4>4.1 \u751f\u547d\u5468\u671f\u4e0e\u8fd4\u56de\u503c\u7ea6\u5b9a<\/h4>\n<p>Socket() \u7f6e _sockfd &#061; -1&#xff0c;Socket(int) \u63a5\u7ba1\u5916\u90e8 fd&#xff0c;Fd() \u53d6\u503c&#xff1b;\u6790\u6784 close \u540e\u7f6e -1\u3002Close() \u53ea close \u4e0d\u590d\u4f4d _sockfd&#xff0c;\u6545\u6790\u6784\u65f6\u4f1a\u5bf9\u540c\u4e00 fd \u518d close \u4e00\u6b21\u3002\u6bcf\u4e2a\u7cfb\u7edf\u8c03\u7528\u5931\u8d25\u8def\u5f84\u90fd\u8d70 ERR_LOG&#xff0c;\u6210\u529f\u7684\u7ec4\u5408\u5165\u53e3\u7528 INF_LOG\u3002<\/p>\n<h4>4.2 \u670d\u52a1\u7aef\u8def\u5f84<\/h4>\n<p>CreateServer(port, ip &#061; &#034;0.0.0.0&#034;) \u4f9d\u6b21 Create \u2192 Bind \u2192 Listen&#xff0c;\u6210\u529f\u540e INF_LOG \u5e76\u8c03 SetReuseAddrPort\u3002Create \u7528 socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)&#xff1b;Bind \u5148 memset \u518d\u586b sin_family\u3001htons(port)&#xff0c;\u5730\u5740\u7531 inet_pton \u5199\u5165 sin_addr&#xff0c;\u65e7\u7684 inet_addr \u5199\u6cd5\u7559\u5728\u6ce8\u91ca\u4e2d&#xff1b;Listen \u7f3a\u7701 MAX_LISTEN &#061; 1024\u3002SetReuseAddrPort \u5bf9 SO_REUSEADDR \u4e0e SO_REUSEPORT \u5404 setsockopt \u4e00\u6b21&#xff0c;\u4f4d\u7f6e\u5728 bind\/listen \u4e4b\u540e&#xff0c;\u5931\u8d25\u53ea\u8bb0\u5f55\u3002<\/p>\n<h4>4.3 \u6536\u53d1\u4e0e\u963b\u585e<\/h4>\n<p>Recv \/ Send \u76f4\u63a5\u8f6c\u53d1\u7cfb\u7edf\u8c03\u7528&#xff0c;n &lt;&#061; 0 \u65f6\u82e5 errno \u4e3a EAGAIN \u6216 EINTR \u8fd4\u56de 0&#xff0c;\u5426\u5219 ERR_LOG \u540e\u8fd4\u56de -1&#xff1b;Send \u53e6\u6709 n &#061;&#061; 0 \u7684\u72ec\u7acb\u65e5\u5fd7\u5206\u652f\u3002SetNonBlockRecv \/ SetNonBlockSend \u4ee5 MSG_DONTWAIT \u8c03\u7528\u3002SetNonBlock \u7528 F_GETFL \u53d6\u6807\u5fd7&#xff0c;\u518d F_SETFL | O_NONBLOCK\u3002\u5ba2\u6237\u7aef\u65b9\u5411 CreateClient \u53ea\u6709 Create \u4e0e Connect&#xff0c;\u4e0d\u542b Bind&#xff0c;Connect \u540c\u6837 memset\u3001htons\u3001inet_pton\u3002<\/p>\n<h4>4.4 \u5f00\u53d1\u4e2d\u9047\u5230\u7684\u95ee\u9898<\/h4>\n<p>bug1&#xff1a;INADDR_ANY \u662f 0 \u4e0d\u662f\u5b57\u7b26\u4e32&#xff0c;\u6781\u6613\u8bef\u4f1a&#xff08;\u6ce8\u91ca\u8bb0 [30min]&#xff09;\u3002\u539f\u5199\u6cd5 const std::string&amp; ip &#061; INADDR_ANY \u5df2\u6ce8\u91ca\u6389&#xff0c;\u73b0\u9ed8\u8ba4\u503c\u4e3a &#034;0.0.0.0&#034;&#xff0c;\u4ecd\u4ea4\u7ed9 inet_pton \u8f6c\u6362\u3002 bug2&#xff1a;\u6d4b\u8bd5\u65f6\u6ce8\u610f&#xff0c;\u76d1\u542c\u5957\u63a5\u5b57\u4e0d\u80fd\u7528\u4e8e\u901a\u4fe1\u3002\u6807\u6ce8\u4f4d\u4e8e Send() \u5185\u3002 bug3&#xff1a;accept \u7684\u7b2c\u4e09\u53c2\u6570\u540c\u65f6\u4f5c\u4e3a\u8f93\u5165\u8f93\u51fa\u53c2\u6570&#xff0c;\u8c03\u7528\u524d\u987b\u7ed9\u51fa\u7f13\u51b2\u533a\u5927\u5c0f&#xff1a;<\/p>\n<p><span class=\"token comment\">\/\/ Accept()<\/span><br \/>\n<span class=\"token comment\">\/\/ \u539f&#xff1a;socklen_t len;<\/span><br \/>\nsocklen_t len <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">sizeof<\/span><span class=\"token punctuation\">(<\/span>client_addr<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<h3>\u603b\u7ed3<\/h3>\n<p>\u5c01\u88c5\u8fb9\u754c\u662f\u5957\u63a5\u5b57\u751f\u547d\u5468\u671f\u52a0\u7cfb\u7edf\u8c03\u7528\u7684\u8fd4\u56de\u5224\u5b9a&#xff1b;\u4e09\u6761\u6ce8\u610f\u5206\u522b\u843d\u5728 Bind\/Connect \u7684 memset\u3001Recv\/Send \u7684 errno \u5206\u652f\u3001CreateClient \u4e0d Bind&#xff0c;bug3 \u6b63\u662f&#034;\u503c-\u7ed3\u679c\u53c2\u6570&#034;\u672a\u4f20\u521d\u503c\u3002bug1 \u5c5e\u7c7b\u578b\u4e0d\u5339\u914d&#xff0c;bug2 \u5c5e\u5957\u63a5\u5b57\u89d2\u8272\u6df7\u7528\u3002<\/p>\n<h3>\u5e38\u89c1\u95ee\u9898<\/h3>\n<li>\u4e3a\u4f55 Bind\u3001Connect \u8981 memset \u800c Accept \u4e0d\u7528&#xff1f;\u524d\u4e24\u8005\u662f\u503c\u4f20\u5165&#xff0c;Accept \u5185\u8986\u76d6\u5f0f\u5199\u5165&#xff0c;client_addr \u65e0\u9700\u6e05\u7a7a\u3002<\/li>\n<li>\u4e3a\u4f55 INADDR_ANY \u4e0d\u80fd\u5f53 std::string \u9ed8\u8ba4\u53c2\u6570&#xff1f;\u5b83\u662f 0 \u800c\u975e\u5b57\u7b26\u4e32&#xff08;bug1&#xff09;&#xff0c;\u73b0\u7528 &#034;0.0.0.0&#034; \u7ecf inet_pton \u8f6c\u6362\u3002<\/li>\n<li>Recv\/Send \u4e2d EAGAIN \u4e0e EINTR \u4e3a\u4f55\u90fd\u8fd4\u56de 0&#xff1f;\u4e8c\u8005\u90fd\u4e0d\u89c6\u4e3a\u81f4\u547d\u9519\u8bef&#xff0c;\u4ea4\u7531\u4e0a\u5c42\u4e0b\u8f6e\u518d\u8bd5\u3002<\/li>\n<li>bug3 \u4e2d len \u4e0d\u521d\u59cb\u5316\u4f1a\u600e\u6837&#xff1f;accept \u628a\u5b83\u5f53\u8f93\u5165\u7f13\u51b2\u533a\u5927\u5c0f&#xff0c;\u672a\u7ed9\u503c\u5373\u672a\u5b9a\u4e49&#xff0c;\u6545\u987b socklen_t len &#061; sizeof(client_addr)\u3002<\/li>\n<h3>\u6807\u7b7e<\/h3>\n<p>C&#043;&#043;\u3001TCP Socket \u5c01\u88c5\u3001inet_pton\u3001EAGAIN\/EINTR\u3001header-only<\/p>\n<p>\u3010\u7edf\u8ba1&#xff1a;\u5168\u6587\u7ea6 1180 \u5b57 \/ \u539f\u4ee3\u7801 256 \u884c \/ \u6bd4\u4f8b\u7ea6 4.6&#xff1b;\u6ce8\u91ca\u5b57\u6bb5\u5c0f\u8282 4 \u4e2a \/ \u6210\u6587 bug 3 \u5904\u3011<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\/* MD \/ \u5bcc\u6587\u672c\u4e2d\u7684 .toc\uff08\u542b\u535a\u5ba2\u56ed\u642c\u5bb6\u7b49\u5d4c\u5957\u7ed3\u6784\uff09\uff1b.toc-box \u5728\u4fa7\u680f\uff0c\u4e0d\u53d7\u5f71\u54cd *\/#content_views .toc,\/* \u7f16\u8f91\u5668\u5e38\u5728\u76ee\u5f55\u524d\u540e\u63d2\u5165\u7a7a p\uff08:empty \u4ecd\u5360 20px\uff09\uff0c\u4e00\u5e76\u53bb\u6389\u907f\u514d\u9876\u7a7a\u9699 *\/#content_views.markdown_views &gt; p:empty:has(+ .toc),#content_views.markdown_views &gt; .toc + p:empty,\/* \u5bcc\u6587\u672c\u65e7\u7248\u76ee\u5f55\u6807\u8bb0 *\/#content<\/p>\n","protected":false},"author":2,"featured_media":115876,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[970,43,44],"topic":[],"class_list":["post-115877","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-tcp","tag-43","tag-44"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u4effmuduo\u5b9e\u73b0\u9ad8\u5e76\u53d1\u670d\u52a1\u5668\u2014\u2014\u7aef\u5bf9\u7aefSocket.hpp - \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\/115877.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u4effmuduo\u5b9e\u73b0\u9ad8\u5e76\u53d1\u670d\u52a1\u5668\u2014\u2014\u7aef\u5bf9\u7aefSocket.hpp - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\/* MD \/ \u5bcc\u6587\u672c\u4e2d\u7684 .toc\uff08\u542b\u535a\u5ba2\u56ed\u642c\u5bb6\u7b49\u5d4c\u5957\u7ed3\u6784\uff09\uff1b.toc-box \u5728\u4fa7\u680f\uff0c\u4e0d\u53d7\u5f71\u54cd *\/#content_views .toc,\/* \u7f16\u8f91\u5668\u5e38\u5728\u76ee\u5f55\u524d\u540e\u63d2\u5165\u7a7a p\uff08:empty \u4ecd\u5360 20px\uff09\uff0c\u4e00\u5e76\u53bb\u6389\u907f\u514d\u9876\u7a7a\u9699 *\/#content_views.markdown_views &gt; p:empty:has(+ .toc),#content_views.markdown_views &gt; .toc + p:empty,\/* \u5bcc\u6587\u672c\u65e7\u7248\u76ee\u5f55\u6807\u8bb0 *\/#content\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/115877.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-10-20T06:01:06+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261020060103-6ad7039f799d6.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=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/115877.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/115877.html\",\"name\":\"\u4effmuduo\u5b9e\u73b0\u9ad8\u5e76\u53d1\u670d\u52a1\u5668\u2014\u2014\u7aef\u5bf9\u7aefSocket.hpp - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-10-20T06:01:06+00:00\",\"dateModified\":\"2026-10-20T06:01:06+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/115877.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/115877.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/115877.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u4effmuduo\u5b9e\u73b0\u9ad8\u5e76\u53d1\u670d\u52a1\u5668\u2014\u2014\u7aef\u5bf9\u7aefSocket.hpp\"}]},{\"@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":"\u4effmuduo\u5b9e\u73b0\u9ad8\u5e76\u53d1\u670d\u52a1\u5668\u2014\u2014\u7aef\u5bf9\u7aefSocket.hpp - \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\/115877.html","og_locale":"zh_CN","og_type":"article","og_title":"\u4effmuduo\u5b9e\u73b0\u9ad8\u5e76\u53d1\u670d\u52a1\u5668\u2014\u2014\u7aef\u5bf9\u7aefSocket.hpp - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\/* MD \/ \u5bcc\u6587\u672c\u4e2d\u7684 .toc\uff08\u542b\u535a\u5ba2\u56ed\u642c\u5bb6\u7b49\u5d4c\u5957\u7ed3\u6784\uff09\uff1b.toc-box \u5728\u4fa7\u680f\uff0c\u4e0d\u53d7\u5f71\u54cd *\/#content_views .toc,\/* \u7f16\u8f91\u5668\u5e38\u5728\u76ee\u5f55\u524d\u540e\u63d2\u5165\u7a7a p\uff08:empty \u4ecd\u5360 20px\uff09\uff0c\u4e00\u5e76\u53bb\u6389\u907f\u514d\u9876\u7a7a\u9699 *\/#content_views.markdown_views &gt; p:empty:has(+ .toc),#content_views.markdown_views &gt; .toc + p:empty,\/* \u5bcc\u6587\u672c\u65e7\u7248\u76ee\u5f55\u6807\u8bb0 *\/#content","og_url":"https:\/\/www.wsisp.com\/helps\/115877.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-10-20T06:01:06+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261020060103-6ad7039f799d6.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/115877.html","url":"https:\/\/www.wsisp.com\/helps\/115877.html","name":"\u4effmuduo\u5b9e\u73b0\u9ad8\u5e76\u53d1\u670d\u52a1\u5668\u2014\u2014\u7aef\u5bf9\u7aefSocket.hpp - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-10-20T06:01:06+00:00","dateModified":"2026-10-20T06:01:06+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/115877.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/115877.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/115877.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u4effmuduo\u5b9e\u73b0\u9ad8\u5e76\u53d1\u670d\u52a1\u5668\u2014\u2014\u7aef\u5bf9\u7aefSocket.hpp"}]},{"@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\/115877","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=115877"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/115877\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/115876"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=115877"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=115877"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=115877"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=115877"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}