{"id":24339,"date":"2025-04-19T09:52:42","date_gmt":"2025-04-19T01:52:42","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/24339.html"},"modified":"2025-04-19T09:52:42","modified_gmt":"2025-04-19T01:52:42","slug":"%e6%9c%8d%e5%8a%a1%e5%99%a8%e5%ae%88%e6%8a%a4%e8%bf%9b%e7%a8%8b%e5%8c%96","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/24339.html","title":{"rendered":"\u670d\u52a1\u5668\u5b88\u62a4\u8fdb\u7a0b\u5316"},"content":{"rendered":"<h2 id=\"main-toc\">\u76ee\u5f55<\/h2>\n<p id=\"%E4%B8%80%E3%80%81%E5%AE%88%E6%8A%A4%E8%BF%9B%E7%A8%8B%E7%9A%84%E5%AE%9A%E4%B9%89%E4%B8%8E%E7%89%B9%E7%82%B9-toc\" style=\"margin-left:40px\">\u4e00\u3001\u5b88\u62a4\u8fdb\u7a0b\u7684\u5b9a\u4e49\u4e0e\u7279\u70b9<\/p>\n<p id=\"1%E3%80%81%E5%AE%9A%E4%B9%89%EF%BC%9A-toc\" style=\"margin-left:80px\">1\u3001\u5b9a\u4e49<\/p>\n<p id=\"2%E3%80%81%E7%89%B9%E7%82%B9%EF%BC%9A-toc\" style=\"margin-left:80px\">2\u3001\u7279\u70b9<\/p>\n<p id=\"%E4%BA%8C%E3%80%81%E5%AE%88%E6%8A%A4%E8%BF%9B%E7%A8%8B%E7%9A%84%E5%8E%9F%E7%90%86-toc\" style=\"margin-left:40px\">\u4e8c\u3001\u5b88\u62a4\u8fdb\u7a0b\u7684\u539f\u7406<\/p>\n<p id=\"%E4%B8%89%E3%80%81%E5%AE%88%E6%8A%A4%E8%BF%9B%E7%A8%8B%E4%B8%8E%E4%BC%9A%E8%AF%9D%EF%BC%88Session%EF%BC%89%E7%9A%84%E5%85%B3%E7%B3%BB-toc\" style=\"margin-left:40px\">\u4e09\u3001\u5b88\u62a4\u8fdb\u7a0b\u4e0e\u4f1a\u8bdd&#xff08;Session&#xff09;\u7684\u5173\u7cfb<\/p>\n<p id=\"%E5%9B%9B%E3%80%81C%2B%2B%E5%AE%9E%E7%8E%B0%E5%AE%88%E6%8A%A4%E8%BF%9B%E7%A8%8B-toc\" style=\"margin-left:40px\">\u56db\u3001C&#043;&#043;\u5b9e\u73b0\u5b88\u62a4\u8fdb\u7a0b<\/p>\n<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u5b88\u62a4\u8fdb\u7a0b&#xff08;Daemon Process&#xff09;\u662f\u4e00\u4e2a\u5728\u540e\u53f0\u8fd0\u884c\u3001\u901a\u5e38\u4e0d\u4e0e\u7528\u6237\u76f4\u63a5\u4ea4\u4e92\u7684\u8fdb\u7a0b\u3002\u5b88\u62a4\u8fdb\u7a0b\u662f\u64cd\u4f5c\u7cfb\u7edf\u4e2d\u975e\u5e38\u91cd\u8981\u7684\u4e00\u90e8\u5206&#xff0c;\u5e38\u89c1\u7684\u5e94\u7528\u5305\u62ec\u7cfb\u7edf\u65e5\u5fd7\u3001\u7f51\u7edc\u670d\u52a1\u3001\u6570\u636e\u5e93\u7ba1\u7406\u7b49\u3002\u5728\u8fd9\u7bc7\u535a\u5ba2\u4e2d&#xff0c;\u6211\u4eec\u5c06\u8be6\u7ec6\u63a2\u8ba8\u5b88\u62a4\u8fdb\u7a0b\u7684\u539f\u7406\u3001\u5982\u4f55\u4e0e\u4f1a\u8bdd\u7ba1\u7406\u8054\u7cfb&#xff0c;\u5e76\u901a\u8fc7C&#043;&#043;\u5b9e\u73b0\u4e00\u4e2a\u7b80\u5355\u7684\u5b88\u62a4\u8fdb\u7a0b\u3002\u5c06\u670d\u52a1\u5668\u5b88\u62a4\u8fdb\u7a0b\u5316\u7684\u4e3b\u8981\u76ee\u7684\u662f\u786e\u4fdd\u670d\u52a1\u5668\u5728\u540e\u53f0\u6301\u7eed\u8fd0\u884c&#xff0c;\u5e76\u5728\u610f\u5916\u5d29\u6e83\u6216\u91cd\u542f\u540e\u81ea\u52a8\u6062\u590d\u3002\u8fd9\u6837\u53ef\u4ee5\u4f7f\u670d\u52a1\u5728\u6ca1\u6709\u4eba\u5de5\u5e72\u9884\u7684\u60c5\u51b5\u4e0b\u957f\u671f\u7a33\u5b9a\u8fd0\u884c&#xff0c;\u5e76\u51cf\u5c11\u7cfb\u7edf\u7ba1\u7406\u7684\u590d\u6742\u5ea6\u3002<\/p>\n<h3 id=\"%E4%B8%80%E3%80%81%E5%AE%88%E6%8A%A4%E8%BF%9B%E7%A8%8B%E7%9A%84%E5%AE%9A%E4%B9%89%E4%B8%8E%E7%89%B9%E7%82%B9\" style=\"background-color:transparent\">\u4e00\u3001\u5b88\u62a4\u8fdb\u7a0b\u7684\u5b9a\u4e49\u4e0e\u7279\u70b9<\/h3>\n<h4 id=\"1%E3%80%81%E5%AE%9A%E4%B9%89%EF%BC%9A\" style=\"background-color:transparent\">1\u3001\u5b9a\u4e49<\/h4>\n<p>\u5b88\u62a4\u8fdb\u7a0b\u662f\u4e00\u4e2a\u6ca1\u6709\u7ec8\u7aef\u63a7\u5236\u7684\u8fdb\u7a0b&#xff0c;\u5b83\u901a\u5e38\u5728\u7cfb\u7edf\u542f\u52a8\u65f6\u542f\u52a8&#xff0c;\u72ec\u7acb\u4e8e\u4efb\u4f55\u7528\u6237\u4f1a\u8bdd&#xff08;session&#xff09;&#xff0c;\u5e76\u4e14\u5728\u540e\u53f0\u6301\u7eed\u8fd0\u884c\u3002\u5b88\u62a4\u8fdb\u7a0b\u7684\u7279\u70b9\u662f\u5b83\u4e0d\u4f9d\u8d56\u4e8e\u7528\u6237\u7684\u8f93\u5165\u8f93\u51fa&#xff0c;\u8fd0\u884c\u65f6\u4e0d\u4f1a\u4ea7\u751f\u7ec8\u7aef\u4ea4\u4e92\u3002<\/p>\n<h4 id=\"2%E3%80%81%E7%89%B9%E7%82%B9%EF%BC%9A\">2\u3001\u7279\u70b9<\/h4>\n<ul>\n<li>\u540e\u53f0\u8fd0\u884c&#xff1a;\u5b88\u62a4\u8fdb\u7a0b\u901a\u5e38\u5728\u64cd\u4f5c\u7cfb\u7edf\u542f\u52a8\u65f6\u542f\u52a8&#xff0c;\u6216\u8005\u5728\u7528\u6237\u767b\u5f55\u540e\u7531\u7cfb\u7edf\u670d\u52a1\u542f\u52a8&#xff0c;\u5e76\u5728\u540e\u53f0\u6301\u7eed\u8fd0\u884c\u3002<\/li>\n<li>\u65e0\u7ec8\u7aef&#xff1a;\u5b88\u62a4\u8fdb\u7a0b\u4e0d\u4e0e\u4efb\u4f55\u7ec8\u7aef\u6216\u7528\u6237\u4f1a\u8bdd\u5173\u8054&#xff0c;\u5b83\u901a\u5e38\u4e0d\u4e0e\u6807\u51c6\u8f93\u5165\u8f93\u51fa&#xff08;stdin, stdout, stderr&#xff09;\u76f8\u5173\u8054\u3002<\/li>\n<li>\u72ec\u7acb\u6027&#xff1a;\u5b88\u62a4\u8fdb\u7a0b\u4e0e\u7528\u6237\u7684\u767b\u5f55\u4f1a\u8bdd\u662f\u72ec\u7acb\u7684&#xff0c;\u5b83\u5728\u540e\u53f0\u9759\u9759\u8fd0\u884c&#xff0c;\u6267\u884c\u7cfb\u7edf\u7ea7\u4efb\u52a1&#xff0c;\u5982\u65e5\u5fd7\u8bb0\u5f55\u3001\u5b9a\u65f6\u4efb\u52a1\u3001\u6587\u4ef6\u6e05\u7406\u7b49\u3002<\/li>\n<li>\u7236\u8fdb\u7a0b\u4e3ainit\u8fdb\u7a0b&#xff1a;\u5b88\u62a4\u8fdb\u7a0b\u5728\u7cfb\u7edf\u542f\u52a8\u65f6\u7531\u7236\u8fdb\u7a0b&#xff08;\u901a\u5e38\u662finit\u8fdb\u7a0b&#xff09;\u542f\u52a8&#xff0c;\u8fd0\u884c\u65f6\u4e0d\u4f1a\u9000\u51fa\u3002<\/li>\n<li>PID&#xff08;\u8fdb\u7a0bID&#xff09;&#xff1a;\u5b88\u62a4\u8fdb\u7a0b\u7684PID\u662f\u7531\u64cd\u4f5c\u7cfb\u7edf\u5206\u914d\u7684&#xff0c;\u5b83\u901a\u5e38\u4f1a\u88ab\u5199\u5165\u5230\u67d0\u4e2a\u6587\u4ef6\u4e2d\u4ee5\u4f9b\u540e\u7eed\u7ba1\u7406\u548c\u7ec8\u6b62\u3002<\/li>\n<\/ul>\n<hr \/>\n<h3 id=\"%E4%BA%8C%E3%80%81%E5%AE%88%E6%8A%A4%E8%BF%9B%E7%A8%8B%E7%9A%84%E5%8E%9F%E7%90%86\">\u4e8c\u3001\u5b88\u62a4\u8fdb\u7a0b\u7684\u539f\u7406<\/h3>\n<p>\u5b88\u62a4\u8fdb\u7a0b\u662f\u901a\u8fc7\u8131\u79bb\u63a7\u5236\u7ec8\u7aef\u3001\u4f7f\u81ea\u5df1\u6210\u4e3a\u4e00\u4e2a\u72ec\u7acb\u7684\u540e\u53f0\u8fdb\u7a0b\u6765\u5b9e\u73b0\u7684\u3002\u8fd9\u662f\u901a\u8fc7\u51e0\u4e2a\u6b65\u9aa4\u5b9e\u73b0\u7684&#xff1a;<\/p>\n<li>\n<p>\u521b\u5efa\u5b50\u8fdb\u7a0b&#xff1a;\u5b88\u62a4\u8fdb\u7a0b\u9996\u5148\u4f1a\u521b\u5efa\u4e00\u4e2a\u5b50\u8fdb\u7a0b&#xff0c;\u7236\u8fdb\u7a0b\u9000\u51fa&#xff0c;\u5b50\u8fdb\u7a0b\u7ee7\u7eed\u6267\u884c&#xff0c;\u8fd9\u6837\u53ef\u4ee5\u8ba9\u5b88\u62a4\u8fdb\u7a0b\u907f\u514d\u4e0e\u4efb\u4f55\u7528\u6237\u4f1a\u8bdd\u6216\u7ec8\u7aef\u76f4\u63a5\u4ea4\u4e92\u3002<\/p>\n<\/li>\n<li>\n<p>\u521b\u5efa\u65b0\u7684\u4f1a\u8bdd&#xff08;Session&#xff09;&#xff1a;\u5b88\u62a4\u8fdb\u7a0b\u901a\u5e38\u4f1a\u8c03\u7528 setsid() \u7cfb\u7edf\u8c03\u7528\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u4f1a\u8bdd&#xff0c;\u6210\u4e3a\u8be5\u4f1a\u8bdd\u7684\u9996\u8fdb\u7a0b\u3002\u65b0\u4f1a\u8bdd\u7684\u521b\u5efa\u610f\u5473\u7740\u5b83\u4e0d\u518d\u4e0e\u539f\u59cb\u7684\u63a7\u5236\u7ec8\u7aef\u548c\u8fdb\u7a0b\u7ec4\u76f8\u5173\u8054\u3002<\/p>\n<\/li>\n<li>\n<p>\u6539\u53d8\u5de5\u4f5c\u76ee\u5f55&#xff1a;\u5b88\u62a4\u8fdb\u7a0b\u901a\u5e38\u4f1a\u8c03\u7528 chdir() \u6765\u66f4\u6539\u5de5\u4f5c\u76ee\u5f55\u3002\u4e3a\u4e86\u907f\u514d\u5360\u7528\u7ec8\u7aef\u7684\u76ee\u5f55&#xff0c;\u5b88\u62a4\u8fdb\u7a0b\u901a\u5e38\u4f1a\u5c06\u5de5\u4f5c\u76ee\u5f55\u66f4\u6539\u4e3a \/\u3002<\/p>\n<\/li>\n<li>\n<p>\u5173\u95ed\u6587\u4ef6\u63cf\u8ff0\u7b26&#xff1a;\u5b88\u62a4\u8fdb\u7a0b\u8fd8\u4f1a\u5173\u95ed\u4e0e\u7ec8\u7aef\u76f8\u5173\u7684\u6587\u4ef6\u63cf\u8ff0\u7b26&#xff0c;\u5305\u62ec\u6807\u51c6\u8f93\u5165&#xff08;stdin&#xff09;\u3001\u6807\u51c6\u8f93\u51fa&#xff08;stdout&#xff09;\u3001\u6807\u51c6\u9519\u8bef&#xff08;stderr&#xff09;\u3002\u901a\u5e38\u4f1a\u5c06\u5b83\u4eec\u91cd\u5b9a\u5411\u5230 \/dev\/null&#xff0c;\u4ee5\u9632\u6b62\u8f93\u51fa\u5230\u7ec8\u7aef\u3002<\/p>\n<\/li>\n<li>\n<p>\u5ffd\u7565\u4fe1\u53f7&#xff1a;\u5b88\u62a4\u8fdb\u7a0b\u4f1a\u8bbe\u7f6e\u9002\u5f53\u7684\u4fe1\u53f7\u5904\u7406&#xff0c;\u907f\u514d\u56e0\u6536\u5230\u5982SIGHUP\u7b49\u4fe1\u53f7\u5bfc\u81f4\u8fdb\u7a0b\u9000\u51fa\u3002<\/p>\n<\/li>\n<p>void Daemon(const std::string &amp;cwd &#061; &#034;&#034;)<br \/>\n{<br \/>\n    \/\/ 1. \u5ffd\u7565\u5176\u4ed6\u5f02\u5e38\u4fe1\u53f7<br \/>\n    signal(SIGCLD, SIG_IGN);<br \/>\n    signal(SIGPIPE, SIG_IGN);<br \/>\n    signal(SIGSTOP, SIG_IGN);<\/p>\n<p>    \/\/ 2. \u5c06\u81ea\u5df1\u53d8\u6210\u72ec\u7acb\u7684\u4f1a\u8bdd<br \/>\n    if (fork() &gt; 0)\/\/&gt;0\u8bf4\u660e\u662f\u7236\u8fdb\u7a0b&#xff0c;\u8ba9\u7236\u8fdb\u7a0b\u76f4\u63a5\u9000\u51fa<br \/>\n        exit(0);<br \/>\n    setsid(); \/\/\u5b50\u8fdb\u7a0b<\/p>\n<p>    \/\/ 3. \u66f4\u6539\u5f53\u524d\u8c03\u7528\u8fdb\u7a0b\u7684\u5de5\u4f5c\u76ee\u5f55<br \/>\n    if (!cwd.empty())<br \/>\n        chdir(cwd.c_str());<\/p>\n<p>    \/\/ 4. \u6807\u51c6\u8f93\u5165&#xff0c;\u6807\u51c6\u8f93\u51fa&#xff0c;\u6807\u51c6\u9519\u8bef\u91cd\u5b9a\u5411\u81f3\/dev\/null \u5783\u573e\u6876<br \/>\n    int fd &#061; open(nullfile.c_str(), O_RDWR);<br \/>\n    if(fd &gt; 0)<br \/>\n    {<br \/>\n        dup2(fd, 0);<br \/>\n        dup2(fd, 1);<br \/>\n        dup2(fd, 2);<br \/>\n        close(fd);<br \/>\n    }<br \/>\n} <\/p>\n<hr \/>\n<h3 id=\"%E4%B8%89%E3%80%81%E5%AE%88%E6%8A%A4%E8%BF%9B%E7%A8%8B%E4%B8%8E%E4%BC%9A%E8%AF%9D%EF%BC%88Session%EF%BC%89%E7%9A%84%E5%85%B3%E7%B3%BB\">\u4e09\u3001\u5b88\u62a4\u8fdb\u7a0b\u4e0e\u4f1a\u8bdd&#xff08;Session&#xff09;\u7684\u5173\u7cfb<\/h3>\n<p>\u4f1a\u8bdd&#xff08;Session&#xff09;\u662f\u4e0e\u8fdb\u7a0b\u3001\u7ec8\u7aef\u548c\u8fdb\u7a0b\u7ec4\u5bc6\u5207\u76f8\u5173\u7684\u6982\u5ff5\u3002\u4f1a\u8bdd\u7684\u4f5c\u7528\u662f\u7ba1\u7406\u4e00\u7ec4\u76f8\u5173\u7684\u8fdb\u7a0b\u3002<\/p>\n<li>\n<p>\u4f1a\u8bdd\u7684\u521b\u5efa&#xff1a;\u6bcf\u4e2a\u767b\u5f55\u7684\u7528\u6237\u4f1a\u8bdd\u90fd\u6709\u4e00\u4e2a\u4f1a\u8bddID&#xff08;Session ID&#xff09;&#xff0c;\u4e00\u4e2a\u4f1a\u8bdd\u53ef\u4ee5\u6709\u591a\u4e2a\u8fdb\u7a0b\u7ec4&#xff08;Process Group&#xff09;&#xff0c;\u800c\u6bcf\u4e2a\u8fdb\u7a0b\u7ec4\u4e2d\u7684\u8fdb\u7a0b\u5171\u4eab\u540c\u4e00\u4e2a\u63a7\u5236\u7ec8\u7aef\u3002<\/p>\n<\/li>\n<li>\n<p>\u8131\u79bb\u63a7\u5236\u7ec8\u7aef&#xff1a;\u5b88\u62a4\u8fdb\u7a0b\u901a\u8fc7 setsid() \u7cfb\u7edf\u8c03\u7528\u6765\u8131\u79bb\u5f53\u524d\u4f1a\u8bdd\u53ca\u5176\u63a7\u5236\u7ec8\u7aef&#xff0c;\u6210\u4e3a\u4e00\u4e2a\u65b0\u7684\u4f1a\u8bdd\u7684\u9996\u8fdb\u7a0b\u3002\u8fd9\u6837&#xff0c;\u5b88\u62a4\u8fdb\u7a0b\u5c31\u4e0d\u518d\u4e0e\u4efb\u4f55\u7ec8\u7aef\u5173\u8054&#xff0c;\u5b83\u53ef\u4ee5\u81ea\u7531\u5730\u8fd0\u884c\u800c\u4e0d\u53d7\u7528\u6237\u7684\u63a7\u5236\u3002<\/p>\n<\/li>\n<li>\n<p>\u63a7\u5236\u7ec8\u7aef&#xff1a;\u4e00\u65e6\u5b88\u62a4\u8fdb\u7a0b\u521b\u5efa\u4e86\u65b0\u7684\u4f1a\u8bdd\u5e76\u6210\u4e3a\u9996\u8fdb\u7a0b&#xff0c;\u5b83\u5c31\u4e0d\u518d\u4e0e\u4efb\u4f55\u63a7\u5236\u7ec8\u7aef\u5173\u8054\u3002\u63a7\u5236\u7ec8\u7aef\u901a\u5e38\u4e0e\u7528\u6237\u7684\u767b\u5f55\u4f1a\u8bdd\u76f8\u5173\u8054&#xff0c;\u4f46\u5b88\u62a4\u8fdb\u7a0b\u4f1a\u65ad\u5f00\u8fd9\u4e00\u5173\u7cfb&#xff0c;\u907f\u514d\u7ec8\u7aef\u8f93\u5165\u6216\u8f93\u51fa\u5e72\u6270\u5176\u8fd0\u884c\u3002<\/p>\n<\/li>\n<li>\n<p>\u8fdb\u7a0b\u7ec4\u4e0e\u4fe1\u53f7\u5904\u7406&#xff1a;\u4f1a\u8bdd\u4e2d\u7684\u8fdb\u7a0b\u901a\u5e38\u5171\u4eab\u8fdb\u7a0b\u7ec4&#xff0c;\u800c\u8fdb\u7a0b\u7ec4\u7684\u63a7\u5236\u7531\u4f1a\u8bdd\u9996\u8fdb\u7a0b\u7ba1\u7406\u3002\u5b88\u62a4\u8fdb\u7a0b\u901a\u5e38\u4f1a\u8bbe\u7f6e\u4fe1\u53f7\u5904\u7406\u673a\u5236&#xff0c;\u4f7f\u5176\u80fd\u591f\u7ba1\u7406\u6765\u81ea\u8fdb\u7a0b\u7ec4\u7684\u4fe1\u53f7\u3002<\/p>\n<\/li>\n<hr \/>\n<h3 id=\"%E5%9B%9B%E3%80%81C%2B%2B%E5%AE%9E%E7%8E%B0%E5%AE%88%E6%8A%A4%E8%BF%9B%E7%A8%8B\">\u56db\u3001C&#043;&#043;\u5b9e\u73b0\u5b88\u62a4\u8fdb\u7a0b<\/h3>\n<p>#pragma once<\/p>\n<p>#include &lt;iostream&gt;<br \/>\n#include &lt;cstdlib&gt;<br \/>\n#include &lt;unistd.h&gt;<br \/>\n#include &lt;signal.h&gt;<br \/>\n#include &lt;string&gt;<br \/>\n#include &lt;sys\/types.h&gt;<br \/>\n#include &lt;sys\/stat.h&gt;<br \/>\n#include &lt;fcntl.h&gt;<\/p>\n<p>const std::string nullfile &#061; &#034;\/dev\/null&#034;;<\/p>\n<p>void Daemon(const std::string &amp;cwd &#061; &#034;&#034;)<br \/>\n{<br \/>\n    \/\/ 1. \u5ffd\u7565\u5176\u4ed6\u5f02\u5e38\u4fe1\u53f7<br \/>\n    signal(SIGCLD, SIG_IGN);<br \/>\n    signal(SIGPIPE, SIG_IGN);<br \/>\n    signal(SIGSTOP, SIG_IGN);<\/p>\n<p>    \/\/ 2. \u5c06\u81ea\u5df1\u53d8\u6210\u72ec\u7acb\u7684\u4f1a\u8bdd<br \/>\n    if (fork() &gt; 0)\/\/&gt;0\u8bf4\u660e\u662f\u7236\u8fdb\u7a0b&#xff0c;\u8ba9\u7236\u8fdb\u7a0b\u76f4\u63a5\u9000\u51fa<br \/>\n        exit(0);<br \/>\n    setsid(); \/\/\u5b50\u8fdb\u7a0b<\/p>\n<p>    \/\/ 3. \u66f4\u6539\u5f53\u524d\u8c03\u7528\u8fdb\u7a0b\u7684\u5de5\u4f5c\u76ee\u5f55<br \/>\n    if (!cwd.empty())<br \/>\n        chdir(cwd.c_str());<\/p>\n<p>    \/\/ 4. \u6807\u51c6\u8f93\u5165&#xff0c;\u6807\u51c6\u8f93\u51fa&#xff0c;\u6807\u51c6\u9519\u8bef\u91cd\u5b9a\u5411\u81f3\/dev\/null \u5783\u573e\u6876<br \/>\n    int fd &#061; open(nullfile.c_str(), O_RDWR);<br \/>\n    if(fd &gt; 0)<br \/>\n    {<br \/>\n        dup2(fd, 0);<br \/>\n        dup2(fd, 1);<br \/>\n        dup2(fd, 2);<br \/>\n        close(fd);<br \/>\n    }<br \/>\n}<br \/>\n#pragma once<\/p>\n<p>#include &lt;iostream&gt;<br \/>\n#include &lt;string&gt;<br \/>\n#include &lt;cstdlib&gt;<br \/>\n#include &lt;cstring&gt;<br \/>\n#include &lt;unistd.h&gt;<br \/>\n#include &lt;sys\/wait.h&gt;<br \/>\n#include &lt;sys\/types.h&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;<br \/>\n#include &lt;pthread.h&gt;<br \/>\n#include &lt;signal.h&gt;<br \/>\n#include &lt;signal.h&gt;<br \/>\n#include &#034;Log.hpp&#034;<br \/>\n#include &#034;ThreadPool.hpp&#034;<br \/>\n#include &#034;Task.hpp&#034;<br \/>\n#include &#034;Daemon.hpp&#034;<\/p>\n<p>const int defaultfd &#061; -1;<br \/>\nconst std::string defaultip &#061; &#034;0.0.0.0&#034;;<br \/>\nconst int backlog &#061; 10; \/\/ \u4f46\u662f\u4e00\u822c\u4e0d\u8981\u8bbe\u7f6e\u7684\u592a\u5927<br \/>\nextern Log lg;<\/p>\n<p>enum<br \/>\n{<br \/>\n    UsageError &#061; 1,<br \/>\n    SocketError,<br \/>\n    BindError,<br \/>\n    ListenError,<br \/>\n};<\/p>\n<p>class TcpServer;<\/p>\n<p>class ThreadData<br \/>\n{<br \/>\npublic:<br \/>\n    ThreadData(int fd, const std::string &amp;ip, const uint16_t &amp;p, TcpServer *t): sockfd(fd), clientip(ip), clientport(p), tsvr(t)<br \/>\n    {}<br \/>\npublic:<br \/>\n    int sockfd;<br \/>\n    std::string clientip;<br \/>\n    uint16_t clientport;<br \/>\n    TcpServer *tsvr;<br \/>\n};<\/p>\n<p>class TcpServer<br \/>\n{<br \/>\npublic:<br \/>\n    TcpServer(const uint16_t &amp;port, const std::string &amp;ip &#061; defaultip) : listensock_(defaultfd), port_(port), ip_(ip)<br \/>\n    {<br \/>\n    }<br \/>\n    void InitServer()<br \/>\n    {<br \/>\n        listensock_ &#061; socket(AF_INET, SOCK_STREAM, 0);<br \/>\n        if (listensock_ &lt; 0)<br \/>\n        {<br \/>\n            lg(Fatal, &#034;create socket, errno: %d, errstring: %s&#034;, errno, strerror(errno));<br \/>\n            exit(SocketError);<br \/>\n        }<br \/>\n        lg(Info, &#034;create socket success, listensock_: %d&#034;, listensock_);<\/p>\n<p>        int opt &#061; 1;<br \/>\n        setsockopt(listensock_, SOL_SOCKET, SO_REUSEADDR|SO_REUSEPORT, &amp;opt, sizeof(opt)); \/\/ \u9632\u6b62\u5076\u53d1\u6027\u7684\u670d\u52a1\u5668\u65e0\u6cd5\u8fdb\u884c\u7acb\u5373\u91cd\u542f(tcp\u534f\u8bae\u7684\u65f6\u5019\u518d\u8bf4)<\/p>\n<p>        struct sockaddr_in local;<br \/>\n        memset(&amp;local, 0, sizeof(local));<br \/>\n        local.sin_family &#061; AF_INET;<br \/>\n        local.sin_port &#061; htons(port_);<br \/>\n        inet_aton(ip_.c_str(), &amp;(local.sin_addr));<br \/>\n        \/\/ local.sin_addr.s_addr &#061; INADDR_ANY;<\/p>\n<p>        if (bind(listensock_, (struct sockaddr *)&amp;local, sizeof(local)) &lt; 0)<br \/>\n        {<br \/>\n            lg(Fatal, &#034;bind error, errno: %d, errstring: %s&#034;, errno, strerror(errno));<br \/>\n            exit(BindError);<br \/>\n        }<\/p>\n<p>        lg(Info, &#034;bind socket success, listensock_: %d&#034;, listensock_);<\/p>\n<p>        \/\/ Tcp\u662f\u9762\u5411\u8fde\u63a5\u7684&#xff0c;\u670d\u52a1\u5668\u4e00\u822c\u662f\u6bd4\u8f83\u201c\u88ab\u52a8\u7684\u201d&#xff0c;\u670d\u52a1\u5668\u4e00\u76f4\u5904\u4e8e\u4e00\u79cd&#xff0c;\u4e00\u76f4\u5728\u7b49\u5f85\u8fde\u63a5\u5230\u6765\u7684\u72b6\u6001<br \/>\n        if (listen(listensock_, backlog) &lt; 0)<br \/>\n        {<br \/>\n            lg(Fatal, &#034;listen error, errno: %d, errstring: %s&#034;, errno, strerror(errno));<br \/>\n            exit(ListenError);<br \/>\n        }<\/p>\n<p>        lg(Info, &#034;listen socket success, listensock_: %d&#034;, listensock_);<br \/>\n    }<br \/>\n    void Start()<br \/>\n    {<br \/>\n        Daemon();<br \/>\n        ThreadPool&lt;Task&gt;::GetInstance()-&gt;Start();<br \/>\n        \/\/ for fork();<br \/>\n        \/\/ signal(SIGCHLD, SIG_IGN);<br \/>\n        lg(Info, &#034;tcpServer is running&#8230;.&#034;);<br \/>\n        for (;;)<br \/>\n        {<br \/>\n            \/\/ 1. \u83b7\u53d6\u65b0\u8fde\u63a5<br \/>\n            struct sockaddr_in client;<br \/>\n            socklen_t len &#061; sizeof(client);<br \/>\n            int sockfd &#061; accept(listensock_, (struct sockaddr *)&amp;client, &amp;len);<br \/>\n            if (sockfd &lt; 0)<br \/>\n            {<br \/>\n                lg(Warning, &#034;accept error, errno: %d, errstring: %s&#034;, errno, strerror(errno)); \/\/?<br \/>\n                continue;<br \/>\n            }<br \/>\n            uint16_t clientport &#061; ntohs(client.sin_port);<br \/>\n            char clientip[32];<br \/>\n            inet_ntop(AF_INET, &amp;(client.sin_addr), clientip, sizeof(clientip));<\/p>\n<p>            \/\/ version 4 &#8212; \u7ebf\u7a0b\u6c60\u7248\u672c<br \/>\n            Task t(sockfd, clientip, clientport);<br \/>\n            ThreadPool&lt;Task&gt;::GetInstance()-&gt;Push(t);<br \/>\n        }<br \/>\n    }<br \/>\n    ~TcpServer() {}<\/p>\n<p>private:<br \/>\n    int listensock_;<br \/>\n    uint16_t port_;<br \/>\n    std::string ip_;<br \/>\n};<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"65\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250419015241-680301e919ec9.png\" width=\"664\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"130\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250419015241-680301e934521.png\" width=\"936\" \/><\/p>\n<p>\u8868\u793a\u670d\u52a1\u5df2\u7ecf\u542f\u52a8<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb919\u6b21\uff0c\u70b9\u8d5e30\u6b21\uff0c\u6536\u85cf18\u6b21\u3002\u5b88\u62a4\u8fdb\u7a0b\u662f\u4e00\u4e2a\u6ca1\u6709\u7ec8\u7aef\u63a7\u5236\u7684\u8fdb\u7a0b\uff0c\u5b83\u901a\u5e38\u5728\u7cfb\u7edf\u542f\u52a8\u65f6\u542f\u52a8\uff0c\u72ec\u7acb\u4e8e\u4efb\u4f55\u7528\u6237\u4f1a\u8bdd\uff08session\uff09\uff0c\u5e76\u4e14\u5728\u540e\u53f0\u6301\u7eed\u8fd0\u884c\u3002\uff1a\u6bcf\u4e2a\u767b\u5f55\u7684\u7528\u6237\u4f1a\u8bdd\u90fd\u6709\u4e00\u4e2a\u4f1a\u8bddID\uff08Session ID\uff09\uff0c\u4e00\u4e2a\u4f1a\u8bdd\u53ef\u4ee5\u6709\u591a\u4e2a\u8fdb\u7a0b\u7ec4\uff08Process Group\uff09\uff0c\u800c\u6bcf\u4e2a\u8fdb\u7a0b\u7ec4\u4e2d\u7684\u8fdb\u7a0b\u5171\u4eab\u540c\u4e00\u4e2a\u63a7\u5236\u7ec8\u7aef\u3002\u7cfb\u7edf\u8c03\u7528\u6765\u8131\u79bb\u5f53\u524d\u4f1a\u8bdd\u53ca\u5176\u63a7\u5236\u7ec8\u7aef\uff0c\u6210\u4e3a\u4e00\u4e2a\u65b0\u7684\u4f1a\u8bdd\u7684\u9996\u8fdb\u7a0b\u3002\uff1a\u4f1a\u8bdd\u4e2d\u7684\u8fdb\u7a0b\u901a\u5e38\u5171\u4eab\u8fdb\u7a0b\u7ec4\uff0c\u800c\u8fdb\u7a0b\u7ec4\u7684\u63a7\u5236\u7531\u4f1a\u8bdd\u9996\u8fdb\u7a0b\u7ba1\u7406\u3002\uff1a\u5b88\u62a4\u8fdb\u7a0b\u9996\u5148\u4f1a\u521b\u5efa\u4e00\u4e2a\u5b50\u8fdb\u7a0b\uff0c\u7236\u8fdb\u7a0b\u9000\u51fa\uff0c\u5b50\u8fdb\u7a0b\u7ee7\u7eed\u6267\u884c\uff0c\u8fd9\u6837\u53ef\u4ee5\u8ba9\u5b88\u62a4\u8fdb\u7a0b\u907f\u514d\u4e0e\u4efb\u4f55\u7528\u6237\u4f1a\u8bdd\u6216\u7ec8\u7aef\u76f4\u63a5\u4ea4\u4e92\u3002_\u670d\u52a1\u5668\u5b88\u62a4\u8fdb\u7a0b<\/p>\n","protected":false},"author":2,"featured_media":24337,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[58,970,43],"topic":[],"class_list":["post-24339","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-linux","tag-tcp","tag-43"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u670d\u52a1\u5668\u5b88\u62a4\u8fdb\u7a0b\u5316 - \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\/24339.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u670d\u52a1\u5668\u5b88\u62a4\u8fdb\u7a0b\u5316 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb919\u6b21\uff0c\u70b9\u8d5e30\u6b21\uff0c\u6536\u85cf18\u6b21\u3002\u5b88\u62a4\u8fdb\u7a0b\u662f\u4e00\u4e2a\u6ca1\u6709\u7ec8\u7aef\u63a7\u5236\u7684\u8fdb\u7a0b\uff0c\u5b83\u901a\u5e38\u5728\u7cfb\u7edf\u542f\u52a8\u65f6\u542f\u52a8\uff0c\u72ec\u7acb\u4e8e\u4efb\u4f55\u7528\u6237\u4f1a\u8bdd\uff08session\uff09\uff0c\u5e76\u4e14\u5728\u540e\u53f0\u6301\u7eed\u8fd0\u884c\u3002\uff1a\u6bcf\u4e2a\u767b\u5f55\u7684\u7528\u6237\u4f1a\u8bdd\u90fd\u6709\u4e00\u4e2a\u4f1a\u8bddID\uff08Session ID\uff09\uff0c\u4e00\u4e2a\u4f1a\u8bdd\u53ef\u4ee5\u6709\u591a\u4e2a\u8fdb\u7a0b\u7ec4\uff08Process Group\uff09\uff0c\u800c\u6bcf\u4e2a\u8fdb\u7a0b\u7ec4\u4e2d\u7684\u8fdb\u7a0b\u5171\u4eab\u540c\u4e00\u4e2a\u63a7\u5236\u7ec8\u7aef\u3002\u7cfb\u7edf\u8c03\u7528\u6765\u8131\u79bb\u5f53\u524d\u4f1a\u8bdd\u53ca\u5176\u63a7\u5236\u7ec8\u7aef\uff0c\u6210\u4e3a\u4e00\u4e2a\u65b0\u7684\u4f1a\u8bdd\u7684\u9996\u8fdb\u7a0b\u3002\uff1a\u4f1a\u8bdd\u4e2d\u7684\u8fdb\u7a0b\u901a\u5e38\u5171\u4eab\u8fdb\u7a0b\u7ec4\uff0c\u800c\u8fdb\u7a0b\u7ec4\u7684\u63a7\u5236\u7531\u4f1a\u8bdd\u9996\u8fdb\u7a0b\u7ba1\u7406\u3002\uff1a\u5b88\u62a4\u8fdb\u7a0b\u9996\u5148\u4f1a\u521b\u5efa\u4e00\u4e2a\u5b50\u8fdb\u7a0b\uff0c\u7236\u8fdb\u7a0b\u9000\u51fa\uff0c\u5b50\u8fdb\u7a0b\u7ee7\u7eed\u6267\u884c\uff0c\u8fd9\u6837\u53ef\u4ee5\u8ba9\u5b88\u62a4\u8fdb\u7a0b\u907f\u514d\u4e0e\u4efb\u4f55\u7528\u6237\u4f1a\u8bdd\u6216\u7ec8\u7aef\u76f4\u63a5\u4ea4\u4e92\u3002_\u670d\u52a1\u5668\u5b88\u62a4\u8fdb\u7a0b\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/24339.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-04-19T01:52:42+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250419015241-680301e919ec9.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=\"4 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/24339.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/24339.html\",\"name\":\"\u670d\u52a1\u5668\u5b88\u62a4\u8fdb\u7a0b\u5316 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-04-19T01:52:42+00:00\",\"dateModified\":\"2025-04-19T01:52:42+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/24339.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/24339.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/24339.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u670d\u52a1\u5668\u5b88\u62a4\u8fdb\u7a0b\u5316\"}]},{\"@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":"\u670d\u52a1\u5668\u5b88\u62a4\u8fdb\u7a0b\u5316 - \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\/24339.html","og_locale":"zh_CN","og_type":"article","og_title":"\u670d\u52a1\u5668\u5b88\u62a4\u8fdb\u7a0b\u5316 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb919\u6b21\uff0c\u70b9\u8d5e30\u6b21\uff0c\u6536\u85cf18\u6b21\u3002\u5b88\u62a4\u8fdb\u7a0b\u662f\u4e00\u4e2a\u6ca1\u6709\u7ec8\u7aef\u63a7\u5236\u7684\u8fdb\u7a0b\uff0c\u5b83\u901a\u5e38\u5728\u7cfb\u7edf\u542f\u52a8\u65f6\u542f\u52a8\uff0c\u72ec\u7acb\u4e8e\u4efb\u4f55\u7528\u6237\u4f1a\u8bdd\uff08session\uff09\uff0c\u5e76\u4e14\u5728\u540e\u53f0\u6301\u7eed\u8fd0\u884c\u3002\uff1a\u6bcf\u4e2a\u767b\u5f55\u7684\u7528\u6237\u4f1a\u8bdd\u90fd\u6709\u4e00\u4e2a\u4f1a\u8bddID\uff08Session ID\uff09\uff0c\u4e00\u4e2a\u4f1a\u8bdd\u53ef\u4ee5\u6709\u591a\u4e2a\u8fdb\u7a0b\u7ec4\uff08Process Group\uff09\uff0c\u800c\u6bcf\u4e2a\u8fdb\u7a0b\u7ec4\u4e2d\u7684\u8fdb\u7a0b\u5171\u4eab\u540c\u4e00\u4e2a\u63a7\u5236\u7ec8\u7aef\u3002\u7cfb\u7edf\u8c03\u7528\u6765\u8131\u79bb\u5f53\u524d\u4f1a\u8bdd\u53ca\u5176\u63a7\u5236\u7ec8\u7aef\uff0c\u6210\u4e3a\u4e00\u4e2a\u65b0\u7684\u4f1a\u8bdd\u7684\u9996\u8fdb\u7a0b\u3002\uff1a\u4f1a\u8bdd\u4e2d\u7684\u8fdb\u7a0b\u901a\u5e38\u5171\u4eab\u8fdb\u7a0b\u7ec4\uff0c\u800c\u8fdb\u7a0b\u7ec4\u7684\u63a7\u5236\u7531\u4f1a\u8bdd\u9996\u8fdb\u7a0b\u7ba1\u7406\u3002\uff1a\u5b88\u62a4\u8fdb\u7a0b\u9996\u5148\u4f1a\u521b\u5efa\u4e00\u4e2a\u5b50\u8fdb\u7a0b\uff0c\u7236\u8fdb\u7a0b\u9000\u51fa\uff0c\u5b50\u8fdb\u7a0b\u7ee7\u7eed\u6267\u884c\uff0c\u8fd9\u6837\u53ef\u4ee5\u8ba9\u5b88\u62a4\u8fdb\u7a0b\u907f\u514d\u4e0e\u4efb\u4f55\u7528\u6237\u4f1a\u8bdd\u6216\u7ec8\u7aef\u76f4\u63a5\u4ea4\u4e92\u3002_\u670d\u52a1\u5668\u5b88\u62a4\u8fdb\u7a0b","og_url":"https:\/\/www.wsisp.com\/helps\/24339.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-04-19T01:52:42+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250419015241-680301e919ec9.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"4 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/24339.html","url":"https:\/\/www.wsisp.com\/helps\/24339.html","name":"\u670d\u52a1\u5668\u5b88\u62a4\u8fdb\u7a0b\u5316 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-04-19T01:52:42+00:00","dateModified":"2025-04-19T01:52:42+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/24339.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/24339.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/24339.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u670d\u52a1\u5668\u5b88\u62a4\u8fdb\u7a0b\u5316"}]},{"@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\/24339","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=24339"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/24339\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/24337"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=24339"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=24339"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=24339"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=24339"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}