{"id":27350,"date":"2025-04-19T19:21:43","date_gmt":"2025-04-19T11:21:43","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/27350.html"},"modified":"2025-04-19T19:21:43","modified_gmt":"2025-04-19T11:21:43","slug":"linux%e5%a4%8d%e4%b9%a0-%e4%ba%94%e7%a7%8dio%e6%a8%a1%e5%9e%8b-%e9%98%bb%e5%a1%9eio%e3%80%81%e9%9d%9e%e9%98%bb%e5%a1%9eio%e3%80%81%e4%bf%a1%e5%8f%b7%e9%a9%b1%e5%8a%a8io-io","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/27350.html","title":{"rendered":"[Linux\u590d\u4e60 -- \u4e94\u79cdIO\u6a21\u578b] \u2014\u2014 \u963b\u585eIO\u3001\u975e\u963b\u585eIO\u3001\u4fe1\u53f7\u9a71\u52a8IO IO\u591a\u8def\u8f6c\u63a5\u3001\u5f02\u6b65IO\uff0c\u5305\u62ec\u76f8\u5173\u63a5\u53e3\u7684\u4f7f\u7528\u3001select \u3001poll\u3001epoll \u4ee5\u53ca\u901a\u8fc7\u8fd9\u4e9b\u63a5\u53e3\u5c01\u88c5\u670d\u52a1\u5668"},"content":{"rendered":"<h2>1 \u4e94\u79cdIO\u6a21\u578b<\/h2>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u963b\u585eIO&#xff1a;\u5728\u5185\u6838\u6570\u636e\u51c6\u5907\u597d\u524d&#xff0c;\u7cfb\u7edf\u8c03\u7528\u4f1a\u4e00\u76f4\u7b49\u5f85\u3002\u6240\u6709\u7684\u5957\u63a5\u5b57\u9ed8\u8ba4\u90fd\u662f\u963b\u585e\u65b9\u5f0f<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"806\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250419112134-6803873ebc5f9.png\" width=\"1200\" \/><\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u975e\u963b\u585eIO&#xff1a;\u5982\u679c\u7cfb\u7edf\u672a\u5c06\u6570\u636e\u51c6\u5907\u597d&#xff0c;\u7cfb\u7edf\u8c03\u7528\u4ecd\u4f1a\u76f4\u63a5\u8fd4\u56de&#xff0c;\u5e76\u4e14\u8fd4\u56deEWOULDBLOCK\u9519\u8bef\u7801\u3002<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u4e00\u822c\u6765\u8bb2\u5bf9\u4e8e\u4e00\u4e2a\u53ef\u80fd\u4ea7\u751f\u6570\u636e\u7684\u6587\u4ef6\u63cf\u8ff0\u7b26\u6211\u4eec\u5e0c\u671b\u5728\u4ed6\u6709\u6570\u636e\u65f6\u5c31\u5c06\u6570\u636e\u8bfb\u4e0a\u6765&#xff0c;\u4f46\u662f\u975e\u963b\u585eIO\u76f4\u63a5\u5c31\u8fd4\u56de\u4e86\u5e76\u4e0d\u80fd\u8fbe\u5230\u8fd9\u4e2a\u6548\u679c&#xff0c;\u5982\u679c\u8981\u901a\u8fc7\u975e\u963b\u585eIO\u6765\u8fbe\u5230\u8fd9\u4e2a\u76ee\u7684&#xff0c;\u5c31\u9700\u8981\u4e0d\u65ad\u7684\u5c1d\u8bd5\u8bfb\u5199\u6587\u4ef6\u63cf\u8ff0\u7b26&#xff0c;\u8fd9\u4e2a\u6539\u6210\u79f0\u4e3a<span style=\"color:#fe2c24\">\u8f6e\u8be2<\/span><span style=\"color:#0d0016\">&#xff0c;\u4f46\u662f\u8f6e\u8be2\u662f\u5bf9CPU\u7684\u4e00\u79cd\u6781\u5927\u7684\u6d6a\u8d39&#xff0c;\u4e00\u822c\u53ea\u5728\u7279\u6b8a\u60c5\u51b5\u4e0b\u4f7f\u7528\u3002<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"752\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250419112135-6803873f335e7.png\" width=\"1200\" \/><\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u4fe1\u53f7\u9a71\u52a8IO&#xff1a;\u5185\u6838\u5c06\u6570\u636e\u51c6\u5907\u597d\u65f6&#xff0c;\u4f7f\u7528SIGIO\u4fe1\u53f7\u901a\u77e5\u5e94\u7528\u7a0b\u5e8f\u8fdb\u884cIO\u64cd\u4f5c<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"689\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250419112135-6803873fca9c4.png\" width=\"1004\" \/><\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 IO\u591a\u8def\u8f6c\u63a5&#xff1a;\u4ece\u6d41\u7a0b\u56fe\u4e0a\u770b\u548c\u963b\u585eIO\u7c7b\u4f3c&#xff0c;\u4f46\u662fIO\u591a\u8def\u8f6c\u63a5\u7684\u6838\u5fc3\u5728\u4e8e\u80fd\u591f\u540c\u65f6\u7b49\u5f85\u591a\u4e2a\u6587\u4ef6\u63cf\u8ff0\u7b26\u7684\u5c31\u7eea\u72b6\u6001\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"663\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250419112136-680387401ccbb.png\" width=\"922\" \/>\u00a0 \u00a0 \u00a0 \u00a0 \u5f02\u6b65IO&#xff1a;\u7531\u5185\u6838\u5728\u6570\u636e\u62f7\u8d1d\u5b8c\u6210\u65f6&#xff0c;\u901a\u77e5\u5e94\u7528\u7a0b\u5e8f&#xff08;\u4fe1\u53f7\u9a71\u52a8\u662f\u544a\u8bc9\u5e94\u7528\u7a0b\u5e8f\u4f55\u65f6\u53ef\u4ee5\u5f00\u59cb\u62f7\u8d1d\u6570\u636e&#xff09;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"782\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250419112136-6803874068777.png\" width=\"923\" \/><\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u5c0f\u7ed3&#xff1a;\u4efb\u4f55IO\u8fc7\u7a0b\u4e2d&#xff0c;\u90fd\u5305\u542b\u4e24\u4e2a\u6b65\u9aa4&#xff0c;\u7b2c\u4e00\u4e2a\u662f\u7b49\u5f85&#xff0c;\u7b2c\u4e8c\u4e2a\u662f\u62f7\u8d1d&#xff0c;\u800c\u4e14\u5728\u5b9e\u9645\u7684\u5e94\u7528\u573a\u666f\u4e2d&#xff0c;\u7b49\u5f85\u6d88\u8017\u7684\u65f6\u95f4\u8fdc\u8fdc\u9ad8\u4e8e\u62f7\u8d1d\u7684\u65f6\u95f4&#xff0c;\u8ba9IO\u66f4\u9ad8\u6548&#xff0c;\u6700\u6838\u5fc3\u7684\u65b9\u6cd5\u5c31\u662f\u8ba9\u7b49\u5f85\u7684\u65f6\u95f4\u5c3d\u91cf\u7684\u5c11<\/p>\n<h2>2 \u9ad8\u7ea7IO\u7684\u91cd\u8981\u6982\u5ff5<\/h2>\n<h3>2.1 \u540c\u6b65\u901a\u4fe1\u00a0 vs\u00a0 \u5f02\u6b65\u901a\u4fe1<\/h3>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u540c\u6b65\u548c\u5f02\u6b65\u5173\u6ce8\u7684\u662f\u6d88\u606f\u901a\u4fe1\u673a\u5236<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u6240\u8c13\u540c\u6b65&#xff0c;\u5c31\u662f\u5728\u53d1\u51fa\u4e00\u4e2a\u8c03\u7528\u65f6&#xff0c;\u5728\u6ca1\u6709\u5f97\u5230\u7ed3\u679c\u4e4b\u524d&#xff0c;\u8be5\u8c03\u7528\u5c31\u4e0d\u8fd4\u56de&#xff0c;\u4f46\u662f\u4e00\u65e6\u8c03\u7528\u8fd4\u56de&#xff0c;\u5c31\u5f97\u5230\u8fd4\u56de\u503c\u4e86&#xff1b;<span style=\"color:#777777\">\u6362\u53e5\u8bdd\u8bf4&#xff0c;\u5c31\u662f\u7531<\/span><span style=\"color:#777777\">\u8c03\u7528\u8005<\/span><span style=\"color:#777777\">\u4e3b\u52a8\u7b49\u5f85\u8fd9\u4e2a<\/span><span style=\"color:#777777\">\u8c03\u7528<\/span><span style=\"color:#777777\">\u7684\u7ed3\u679c<\/span><span style=\"color:#777777\">;<\/span><\/p>\n<p><span style=\"color:#777777\">\u00a0 \u00a0 \u00a0 \u00a0 \u5f02\u6b65\u5219\u662f\u76f8\u53cd&#xff0c;\u8c03\u7528\u5728\u53d1\u51fa\u4e4b\u540e&#xff0c;\u8fd9\u4e2a\u8c03\u7528\u5c31\u76f4\u63a5\u8fd4\u56de\u4e86&#xff0c;\u6240\u4ee5\u6ca1\u6709\u8fd4\u56de\u7ed3\u679c; \u6362\u53e5\u8bdd\u8bf4&#xff0c;\u5f53\u4e00\u4e2a\u5f02\u6b65\u8fc7\u7a0b\u8c03\u7528\u53d1\u51fa\u540e&#xff0c;\u8c03\u7528\u8005\u4e0d\u4f1a\u7acb\u523b\u5f97\u5230\u7ed3\u679c; <\/span><span style=\"color:#777777\">\u800c\u662f\u5728<\/span><span style=\"color:#777777\">\u8c03\u7528<\/span><span style=\"color:#777777\">\u53d1\u51fa\u540e&#xff0c;<\/span><span style=\"color:#777777\">\u88ab\u8c03\u7528\u8005<\/span><span style=\"color:#777777\">\u901a\u8fc7\u72b6\u6001\u3001\u901a\u77e5\u6765\u901a\u77e5\u8c03\u7528\u8005&#xff0c;\u6216\u901a\u8fc7\u56de\u8c03\u51fd\u6570\u5904\u7406\u8fd9\u4e2a\u8c03\u7528.<\/span><\/p>\n<h3><span style=\"color:#777777\">2.2 \u963b\u585e\u548c\u975e\u963b\u585e<\/span><\/h3>\n<p><span style=\"color:#777777\">\u00a0 \u00a0 \u00a0 \u00a0 \u963b\u585e\u548c\u975e\u963b\u585e\u5173\u6ce8\u7684\u662f\u7a0b\u5e8f\u5728\u7b49\u5f85\u8c03\u7528\u7ed3\u679c\u8fd4\u56de\u65f6\u7684\u72b6\u6001\u3002<\/span><\/p>\n<p><span style=\"color:#777777\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u963b\u585e\u8c03\u7528\u662f\u6307\u8c03\u7528\u7ed3\u679c\u8fd4\u56de\u4e4b\u524d&#xff0c;\u5f53\u524d\u7ebf\u7a0b\u4f1a\u88ab\u6302\u8d77. <\/span><span style=\"color:#777777\">\u8c03\u7528\u7ebf\u7a0b\u53ea\u6709\u5728\u5f97\u5230\u7ed3\u679c\u4e4b\u540e\u624d\u4f1a\u8fd4\u56de. \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u975e\u963b\u585e\u8c03\u7528\u6307\u5728\u4e0d\u80fd\u7acb\u523b\u5f97\u5230\u7ed3\u679c\u4e4b\u524d&#xff0c;\u8be5\u8c03\u7528\u4e0d\u4f1a\u963b\u585e\u5f53\u524d\u7ebf\u7a0b<\/span><\/p>\n<h2><span style=\"color:#777777\">3 \u8be6\u89e3IO\u6a21\u5f0f\u76f8\u5173\u7684\u63a5\u53e3<\/span><\/h2>\n<h3>3.1 \u975e\u963b\u585eIO<\/h3>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 fcntl\u8fd9\u4e2a\u51fd\u6570\u53ef\u4ee5\u8bbe\u7f6e\u6587\u4ef6\u63cf\u8ff0\u7b26\u7684\u5c5e\u6027<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"468\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250419112136-68038740b273e.png\" width=\"1188\" \/><\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u6211\u4eec\u4ec5\u901a\u8fc7\u7b2c\u4e09\u79cd\u529f\u80fd\u5c31\u53ef\u4ee5\u5c06\u4e00\u4e2a\u6587\u4ef6\u63cf\u8ff0\u7b26\u8bbe\u7f6e\u4e3a\u975e\u963b\u585e<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u5148\u4f7f\u7528F_GETFL\u5c06\u5f53\u524d\u7684\u6587\u4ef6\u63cf\u8ff0\u7b26\u7684\u5c5e\u6027\u53d6\u51fa\u6765&#xff08;\u8fd9\u662f\u4e00\u4e2a\u4f4d\u56fe&#xff09;&#xff0c;\u4e5f\u5c31\u662f\u4ee3\u7801\u4e2d\u7684fl<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u7136\u540e\u4f7f\u7528F_SETFL\u5c06\u6587\u4ef6\u63cf\u8ff0\u7b26\u8bbe\u7f6e\u56de\u53bb\u7684\u540c\u65f6&#xff0c;\u52a0\u4e0a\u4e00\u4e2aO_NONBLOCK\u53c2\u6570<\/p>\n<p>#include &lt;stdio.h&gt;<br \/>\n#include &lt;unistd.h&gt;<br \/>\n#include &lt;fcntl.h&gt;<br \/>\nvoid SetNoBlock(int fd)<br \/>\n{<br \/>\n    int fl &#061; fcntl(fd, F_GETFL);<br \/>\n    if (fl &lt; 0)<br \/>\n    {<br \/>\n        perror(&#034;fcntl&#034;);<br \/>\n        return;<br \/>\n    }<br \/>\n    fcntl(fd, F_SETFL, fl | O_NONBLOCK);<br \/>\n} <\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u4e0b\u9762\u6211\u4eec\u901a\u8fc7\u8f6e\u8be2\u7684\u65b9\u5f0f\u6765\u8bfb\u53d6\u6807\u51c6\u8f93\u5165<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u5b9e\u73b0\u7684\u601d\u8def\u5c31\u662f\u5c06\u6807\u51c6\u8f93\u5165\u8bbe\u7f6e\u4e3a\u975e\u963b\u585e&#xff0c;\u7136\u540e\u4e0d\u65ad\u7684\u4ece\u6807\u51c6\u8f93\u5165\u8bfb\u53d6\u6570\u636e<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/p>\n<p>#include &lt;stdio.h&gt;<br \/>\n#include &lt;unistd.h&gt;<br \/>\n#include &lt;fcntl.h&gt;<br \/>\nvoid SetNoBlock(int fd)<br \/>\n{<br \/>\n    int fl &#061; fcntl(fd, F_GETFL);<br \/>\n    if (fl &lt; 0)<br \/>\n    {<br \/>\n        perror(&#034;fcntl&#034;);<br \/>\n        return;<br \/>\n    }<br \/>\n    fcntl(fd, F_SETFL, fl | O_NONBLOCK);<br \/>\n}<br \/>\nint main()<br \/>\n{<br \/>\n    SetNoBlock(0);<br \/>\n    while (1)<br \/>\n    {<br \/>\n        char buf[1024] &#061; {0};<br \/>\n        ssize_t read_size &#061; read(0, buf, sizeof(buf) &#8211; 1);<br \/>\n        if (read_size &lt; 0)<br \/>\n        {<br \/>\n            perror(&#034;read&#034;);<br \/>\n            sleep(1);<br \/>\n            continue;<br \/>\n        }<br \/>\n        printf(&#034;input:%s\\\\n&#034;, buf);<br \/>\n    }<br \/>\n    return 0;<br \/>\n}<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u8fd0\u884c\u7ed3\u679c\u5982\u56fe<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"901\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250419112137-6803874107b37.png\" width=\"1112\" \/><\/p>\n<h3>3.2 I\/O\u591a\u8def\u8f6c\u63a5\u4e4bselect<\/h3>\n<p>\u8ba4\u8bc6select<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u7cfb\u7edf\u63d0\u4f9b\u7684select\u51fd\u6570\u662f\u7528\u6765\u5b9e\u73b0\u591a\u8def\u590d\u7528\u8f93\u5165\/\u8f93\u51fa\u6a21\u578b<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 select\u7cfb\u7edf\u8c03\u7528\u662f\u7528\u6765\u8ba9\u6211\u4eec\u7684\u7a0b\u5e8f\u76d1\u89c6\u591a\u4e2a\u6587\u4ef6\u63cf\u8ff0\u7b26\u7684\u72b6\u6001\u53d8\u5316\u7684<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u7a0b\u5e8f\u4f1a\u505c\u5728select\u8fd9\u91cc\u7b49\u5f85&#xff0c;\u76f4\u5230\u88ab\u76d1\u89c6\u7684\u6587\u4ef6\u63cf\u8ff0\u7b26\u6709\u4e00\u4e2a\u6216\u591a\u4e2a\u53d1\u751f\u4e86\u72b6\u6001\u53d8\u5316<\/p>\n<p>select\u51fd\u6570\u539f\u578b\u4ee5\u53ca\u76f8\u5173\u53c2\u6570\u7684\u542b\u4e49<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"104\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250419112137-680387418174f.png\" width=\"1030\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"794\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250419112137-68038741aaace.png\" width=\"1200\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"862\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250419112138-680387424cc1e.png\" width=\"1200\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1200\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250419112138-68038742ba766.png\" width=\"1200\" \/><\/p>\n<p>select\u4f7f\u7528\u793a\u4f8b&#xff1a;\u68c0\u6d4b\u6807\u51c6\u8f93\u5165\u8f93\u51fa<\/p>\n<p>#include &lt;iostream&gt;<br \/>\n#include &lt;string&gt;<br \/>\n#include &lt;vector&gt;<br \/>\n#include &lt;unistd.h&gt;<br \/>\n#include &lt;sys\/select.h&gt;<\/p>\n<p>int main()<br \/>\n{<br \/>\n    fd_set fds;<br \/>\n    FD_ZERO(&amp;fds);<br \/>\n    FD_SET(0,&amp;fds);<br \/>\n    for(;;)<br \/>\n    {<br \/>\n        int n &#061; select(1,&amp;fds,NULL,NULL,NULL);<br \/>\n        if(n&lt;0)<br \/>\n        {<br \/>\n            perror(&#034;select&#034;);<br \/>\n            continue;<br \/>\n        }<br \/>\n        if(FD_ISSET(0,&amp;fds))<br \/>\n        {<br \/>\n            char buffer[1024] &#061; {0};<br \/>\n            read(0,buffer,sizeof(buffer));<br \/>\n            printf(&#034;input : %s&#034;,buffer);<br \/>\n        }<br \/>\n        else{<br \/>\n            printf(&#034;error ! invail fd\\\\n&#034;);<br \/>\n            continue;<br \/>\n        }<br \/>\n        FD_ZERO(&amp;fds);<br \/>\n        FD_SET(0,&amp;fds);<br \/>\n    }<br \/>\n    return 0;<br \/>\n} <\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u8fd9\u4e2a\u4ee3\u7801\u7684\u5176\u5b9e\u5c31\u662f\u901a\u8fc7\u68c0\u6d4b\u6807\u51c6\u8f93\u5165\u662f\u5426\u5c31\u7eea\u6765\u5b8c\u6210\u8bfb\u53d6&#xff0c;\u901a\u8fc7\u8fd9\u4e2a\u4ee3\u7801\u5c31\u80fd\u5f88\u660e\u663e\u7684\u770b\u5230select\u7684\u7f3a\u70b9&#xff0c;fds\u5728\u6bcf\u6b21select\u524d\u8981\u91cd\u65b0\u8bbe\u7f6e\u5e76\u4ece\u7528\u6237\u533a\u62f7\u8d1d\u5230\u5185\u6838\u6001&#xff0c;\u8fd9\u76f8\u5f53\u7684\u4e0d\u65b9\u4fbf\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"556\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250419112139-680387435a04c.png\" width=\"1200\" \/><\/p>\n<p>\u901a\u8fc7select\u5b9e\u73b0TCP\u670d\u52a1\u5668<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u6211\u4eec\u5b9a\u4e49\u4e00\u4e2a\u7c7b&#xff0c;\u5728\u8fd9\u4e2a\u7c7b\u4e2d\u7ef4\u62a4\u4e00\u4e2a\u6570\u7ec4\u7528\u6765\u5b58\u653e\u9700\u8981\u5173\u5fc3\u7684\u6587\u4ef6\u63cf\u8ff0\u7b26&#xff0c;\u518d\u5728\u8fd9\u4e2a\u7c7b\u4e2d\u7ef4\u62a4\u4e00\u4e2alistenfd\u7528\u6765\u76d1\u542c\u5ba2\u6237\u7684\u8fde\u63a5\u3002\u5728\u6211\u7684\u4ee3\u7801\u4e2d\u76f8\u5173\u7684\u7f51\u7edc\u5957\u63a5\u5b57\u7f16\u7a0b\u7684\u63a5\u53e3\u662f\u5c01\u88c5\u8fc7\u7684&#xff0c;\u5728\u6587\u672b\u4f1a\u7ed9&#xff0c;\u8fd8\u6709\u65e5\u5fd7\u6587\u4ef6\u6587\u672b\u4e5f\u4f1a\u7ed9\u3002<\/p>\n<p>#include &lt;iostream&gt;<br \/>\n#include &lt;string&gt;<br \/>\n#include &lt;vector&gt;<br \/>\n#include &lt;unistd.h&gt;<br \/>\n#include &lt;sys\/select.h&gt;<br \/>\n#include &#034;Socket.hpp&#034;<\/p>\n<p>#define BUFFERMAX 1024<\/p>\n<p>const int defaultprot &#061; 8888;<br \/>\nconst int defaultfd &#061; 1024;<br \/>\nconst int defaultnot &#061; -1;<\/p>\n<p>class Select_Server<br \/>\n{<br \/>\npublic:<br \/>\n    Select_Server()<br \/>\n    :listenfd_(new Sock)<br \/>\n    {<br \/>\n        for (int i &#061; 0; i &lt; defaultfd; i&#043;&#043;)<br \/>\n            rfds[i] &#061; defaultnot;<br \/>\n    }<br \/>\n    ~Select_Server() {}<\/p>\n<p>public:<br \/>\n    void Init()<br \/>\n    {<br \/>\n        listenfd_-&gt;Socket();<br \/>\n        listenfd_-&gt;Bind(defaultprot);<br \/>\n        listenfd_-&gt;Listen();<br \/>\n    }<br \/>\n    void Start()<br \/>\n    {<br \/>\n        fd_set readfds;<br \/>\n        FD_ZERO(&amp;readfds);<br \/>\n        FD_SET(listenfd_-&gt;Fd(), &amp;readfds);<br \/>\n        rfds[0] &#061; listenfd_-&gt;Fd();<br \/>\n        for (;;)<br \/>\n        {<br \/>\n            int maxfd &#061; 0;<br \/>\n            FD_ZERO(&amp;readfds);<br \/>\n            for (int i &#061; 0; i &lt; defaultfd; i&#043;&#043;)<br \/>\n            {<br \/>\n                if (rfds[i] !&#061; defaultnot)<br \/>\n                {<br \/>\n                    FD_SET(rfds[i], &amp;readfds); \/\/ \u6dfb\u52a0\u8981\u5173\u5fc3\u4e8b\u4ef6\u5230readfds\u91cc<br \/>\n                    if (rfds[i] &gt; maxfd)<br \/>\n                        maxfd &#061; rfds[i];<br \/>\n                }<br \/>\n            }<br \/>\n            \/\/\u8fd9\u91cc\u662fselect\u7684\u4e00\u4e2a\u5f0a\u7aef&#xff0c;\u6bcf\u4e00\u5403\u7b49\u5f85\u4e8b\u4ef6\u524d\u90fd\u8981\u91cd\u65b0\u6dfb\u52a0\u5f85\u5173\u5fc3\u4e8b\u4ef6<\/p>\n<p>            \/\/\u901a\u8fc7select\u7b49\u5f85\u4e8b\u4ef6\u5c31\u7eea<br \/>\n            int n &#061; select(maxfd &#043; 1, &amp;readfds, nullptr, nullptr, nullptr);<br \/>\n            if (n &#061;&#061; 0)<br \/>\n            {<br \/>\n                std::cout &lt;&lt; &#034;timeout &#034; &lt;&lt; std::endl;<br \/>\n            }<br \/>\n            else if (n &#061;&#061; -1)<br \/>\n            {<br \/>\n                std::cout &lt;&lt; &#034;select error&#034; &lt;&lt; std::endl;<br \/>\n                exit(1);<br \/>\n            }<br \/>\n            else<br \/>\n            {<br \/>\n                \/\/ \u610f\u5473\u7740\u6709\u4e8b\u4ef6\u5c31\u7eea<br \/>\n                if (FD_ISSET(listenfd_-&gt;Fd(), &amp;readfds)) \/\/ \u786e\u8ba4\u662f\u4e0d\u662flistenfd<br \/>\n                {<br \/>\n                    \/\/ \u8bf4\u660e\u6709\u94fe\u63a5\u5230\u6765<br \/>\n                    std::string clientip;<br \/>\n                    uint16_t clientport;<br \/>\n                    int sock &#061; listenfd_-&gt;Accept(&amp;clientip, &amp;clientport);<br \/>\n                    \/\/ \u6b64\u65f6\u4e0d\u80fd\u4ecesock\u4e2d\u8bfb\u6570\u636e&#xff0c;\u7406\u89e3\u8bf7\u6c42\u8fde\u63a5\u5e76\u4e0d\u610f\u5473\u7740\u53d1\u6570\u636e<br \/>\n                    int i &#061; 0;<br \/>\n                    for (i &#061; 0; i &lt; defaultfd; i&#043;&#043;)<br \/>\n                    {<br \/>\n                        \/\/ int pos &#061; 0;<br \/>\n                        \/\/ for (; pos &lt; defaultfd; pos&#043;&#043;)<br \/>\n                        \/\/ {<br \/>\n                        \/\/     if (rfds[pos] !&#061; defaultnot)<br \/>\n                        \/\/         continue;<br \/>\n                        \/\/     if (rfds[pos] &#061;&#061; defaultnot)<br \/>\n                        \/\/         break;<br \/>\n                        \/\/ }<br \/>\n                        \/\/ if (pos !&#061; defaultfd)<br \/>\n                        \/\/ {<br \/>\n                        \/\/     rfds[pos] &#061; sock;<br \/>\n                        \/\/     std::cout&lt;&lt;sock&lt;&lt;&#034;Added successfully&#034;;<br \/>\n                        \/\/ }<br \/>\n                        \/\/ else<br \/>\n                        \/\/     std::cout &lt;&lt; &#034;The connection is full&#034; &lt;&lt; std::endl;<br \/>\n                        if(rfds[i] &#061;&#061; defaultnot) break;<br \/>\n                    }<\/p>\n<p>                    if(i &#061;&#061; defaultfd)<br \/>\n                    {<br \/>\n                        std::cout &lt;&lt; &#034;The connection is full&#034; &lt;&lt; std::endl;<br \/>\n                    }<br \/>\n                    else<br \/>\n                    {<br \/>\n                        rfds[i] &#061; sock;<br \/>\n                        std::cout&lt;&lt;sock&lt;&lt;&#034;Added successfully&#034;;<br \/>\n                    }<br \/>\n                }<br \/>\n                else<br \/>\n                {<br \/>\n                    \/\/ \u8bf4\u660e\u8bfb\u4e8b\u4ef6\u5c31\u7eea<br \/>\n                    for (int i &#061; 1; i &lt; defaultfd; i&#043;&#043;)<br \/>\n                    {<br \/>\n                        if (rfds[i] !&#061; defaultnot &amp;&amp; FD_ISSET(rfds[i], &amp;readfds))<br \/>\n                        {<br \/>\n                            char buffer[BUFFERMAX];<br \/>\n                            memset(buffer, 0, sizeof(buffer));<br \/>\n                            \/\/ \u786e\u5b9a\u8981\u8bfb\u7684\u4e8b\u4ef6<br \/>\n                            int m &#061; read(rfds[i], buffer, sizeof(buffer));<br \/>\n                            if (m &#061;&#061; 0)<br \/>\n                            {<br \/>\n                                std::cout &lt;&lt; &#034;Clear Connection&#034; &lt;&lt; std::endl;<br \/>\n                                rfds[i] &#061; defaultnot;<br \/>\n                            }<br \/>\n                            else if (m &#061;&#061; -1)<br \/>\n                                rfds[i] &#061; defaultnot;<br \/>\n                            else<br \/>\n                            {<br \/>\n                                std::cout &lt;&lt; &#034;rfd[&#034;&lt;&lt;i&lt;&lt;&#034;]&#034;&lt;&lt; &#034;buffer:&#034; &lt;&lt; buffer &lt;&lt; std::endl;<br \/>\n                            }<br \/>\n                        }<br \/>\n                    }<br \/>\n                }<br \/>\n            }<br \/>\n        }<br \/>\n    }<\/p>\n<p>private:<br \/>\n    Sock *listenfd_;<br \/>\n    int rfds[defaultfd];<br \/>\n}; <\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0<\/p>\n<p>#include&#034;Socket.hpp&#034;<br \/>\n#include&#034;Log.hpp&#034;<br \/>\n#include&#034;Select_Server.hpp&#034;<br \/>\n#include&lt;memory&gt;<\/p>\n<p>int main()<br \/>\n{<br \/>\n    std::unique_ptr&lt;Select_Server&gt; select(new Select_Server);<br \/>\n    select-&gt;Init();<br \/>\n    select-&gt;Start();<br \/>\n    return 0;<br \/>\n} <\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u8fd0\u884c\u6548\u679c\u5982\u56fe&#xff0c;\u53ef\u4ee5\u5b8c\u6210\u5bf9\u591a\u4e2a\u7528\u6237\u7684\u8bfb\u5199\u3002<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u7b2c\u4e00\u4e2a\u7528\u6237<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"311\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250419112139-68038743b24b6.png\" width=\"936\" \/><\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u7b2c\u4e8c\u4e2a\u7528\u6237<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"381\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250419112139-68038743e2e84.png\" width=\"1028\" \/><\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u7b2c\u4e09\u4e2a\u7528\u6237<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"290\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250419112140-680387442fa0e.png\" width=\"887\" \/><\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u7b2c\u56db\u4e2a\u7528\u6237<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"264\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250419112140-680387445e585.png\" width=\"841\" \/><\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u670d\u52a1\u7aef\u7684\u54cd\u5e94<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"435\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250419112140-680387448b74c.png\" width=\"1200\" \/><\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u8fd9\u4e2a\u4ee3\u7801\u4ec5\u4ec5\u5b8c\u6210\u4e86\u8bfb\u5199\u5e76\u6ca1\u6709\u52a0\u5176\u4ed6\u7684\u529f\u80fd&#xff0c;\u4f60\u4eec\u53ef\u4ee5\u901a\u8fc7\u5b9a\u5236\u534f\u8bae\u6765\u9650\u5b9a\u6570\u636e\u683c\u5f0f\u6765\u5b8c\u6210\u5176\u4ed6\u7684\u529f\u80fd&#xff0c;\u6bd4\u5982\u8bbe\u8ba1\u4e00\u4e2aselect\u7f51\u7edc\u7248\u672c\u8ba1\u7b97\u673a&#xff0c;\u6216\u8005\u4e00\u4e2aselect\u7f51\u7edc\u7248\u672c\u5b57\u5178\u3002<\/p>\n<h3>3.3 I\/O\u591a\u8def\u8f6c\u63a5\u4e4bpoll&#xff08;\u4e86\u89e3\u5373\u53ef&#xff09;<\/h3>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"232\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250419112140-68038744d42d7.png\" width=\"1200\" \/><\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u8bf4\u767d\u4e86\u5176\u5b9epoll\u5c31\u662f\u9488\u5bf9select\u7684\u7f3a\u70b9\u8bbe\u8ba1\u7684&#xff0c;\u4f60select\u9700\u8981\u91cd\u590d\u8bbe\u8ba1\u5f85\u5173\u5fc3\u4e8b\u4ef6&#xff0c;\u6211\u5c31poll\u5c31\u901a\u8fc7\u4e00\u4e2a\u7ed3\u6784\u4f53\u6765\u5b8c\u6210\u4e8b\u4ef6\u5b58\u50a8&#xff0c;\u76d1\u542c\u7684\u4e8b\u4ef6&#xff0c;\u8fd4\u56de\u4e8b\u4ef6\u96c6\u5408&#xff0c;\u8fd9\u6837\u5c31\u8fbe\u5230\u4e86\u4f18\u5316\u7684\u76ee\u7684<\/p>\n<p>\u00a0poll\u7684\u4f18\u70b9&#xff1a;<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 pollfd\u7ed3\u6784\u5305\u542b\u4e86\u8981\u76d1\u89c6\u7684event\u548c\u53d1\u751f\u7684event&#xff0c;\u4e0d\u518d\u4f7f\u7528select&#034;\u53c2\u6570-\u503c&#034;\u4f20\u9012\u7684\u65b9\u5f0f&#xff0c;\u63a5\u53e3\u4f7f\u7528\u6bd4select\u65b9\u4fbf<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 poll\u6ca1\u6709\u6700\u5927\u6570\u91cf\u9650\u5236&#xff0c;\u4f46\u662f\u6570\u91cf\u8fc7\u5927\u6027\u80fd\u4f1a\u4e0b\u964d\u00a0<\/p>\n<p>poll\u7684\u7f3a\u70b9&#xff1a;<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u548cselect\u51fd\u6570\u4e00\u6837&#xff0c;poll\u8fd4\u56de\u540e&#xff0c;\u9700\u8981\u8f6e\u8be2pollfd\u6765\u83b7\u53d6\u5c31\u7eea\u7684\u63cf\u8ff0\u7b26<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u6bcf\u6b21\u8c03\u7528poll\u90fd\u9700\u8981\u628a\u5927\u91cf\u7684pollfd\u7ed3\u6784\u4ece\u7528\u6237\u6001\u62f7\u8d1d\u5230\u5185\u6838\u4e2d<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"color:#777777\">\u540c\u65f6\u8fde\u63a5\u7684\u5927\u91cf\u5ba2\u6237\u7aef\u5728\u4e00\u65f6\u523b\u53ef\u80fd\u53ea\u6709\u5f88\u5c11\u7684\u5904\u4e8e\u5c31\u7eea\u72b6\u6001, <\/span><span style=\"color:#777777\">\u56e0\u6b64\u968f\u7740\u76d1\u89c6\u7684\u63cf\u8ff0\u7b26\u6570\u91cf\u7684\u589e\u957f<\/span><span style=\"color:#777777\">, <\/span><span style=\"color:#777777\">\u5176\u6548 \u7387\u4e5f\u4f1a\u7ebf\u6027\u4e0b\u964d<\/span><\/p>\n<\/p>\n<p>\u901a\u8fc7poll\u5b9e\u73b0\u4e00\u4e2aTCP\u670d\u52a1\u5668<\/p>\n<p>#include &lt;iostream&gt;<br \/>\n#include &lt;string&gt;<br \/>\n#include &lt;vector&gt;<br \/>\n#include &lt;unistd.h&gt;<br \/>\n#include &lt;sys\/poll.h&gt;<br \/>\n#include &lt;vector&gt;<\/p>\n<p>#include &#034;Socket.hpp&#034;<\/p>\n<p>#define BUFFERMAX 1024<\/p>\n<p>const int defaultprot &#061; 8888;<br \/>\nconst int defaultfd &#061; 64;<br \/>\nconst int defaultnot &#061; -1;<br \/>\nconst int non_event &#061; 0;<\/p>\n<p>class Poll_Server<br \/>\n{<br \/>\npublic:<br \/>\n    Poll_Server()<br \/>\n        : listenfd_(new Sock)<br \/>\n    {<br \/>\n        for (int i &#061; 0; i &lt; defaultfd; i&#043;&#043;)<br \/>\n        {<br \/>\n            read_fds[i].fd &#061; defaultnot;<br \/>\n            read_fds[i].events &#061; non_event;<br \/>\n            read_fds[i].revents &#061; non_event;<br \/>\n        }<br \/>\n    }<br \/>\n    ~Poll_Server() {}<\/p>\n<p>public:<br \/>\n    void Init()<br \/>\n    {<br \/>\n        listenfd_-&gt;Socket();<br \/>\n        listenfd_-&gt;Bind(defaultprot);<br \/>\n        listenfd_-&gt;Listen();<br \/>\n    }<br \/>\n    void Accpet_()<br \/>\n    {<br \/>\n        uint16_t Client_Port &#061; 0;<br \/>\n        std::string Client_ip;<br \/>\n        int newsock &#061; listenfd_-&gt;Accept(&amp;Client_ip, &amp;Client_Port);<br \/>\n        int i &#061; 1;<br \/>\n        for (; i &lt; defaultfd; i&#043;&#043;)<br \/>\n        {<br \/>\n            if (read_fds[i].fd !&#061; defaultnot)<br \/>\n                continue;<br \/>\n            else break;<br \/>\n        }<br \/>\n        read_fds[i].fd &#061; newsock;<br \/>\n        read_fds[i].events &#061; POLLIN;<br \/>\n        read_fds[i].revents &#061; non_event;<br \/>\n        Print_Fd();<br \/>\n    }<br \/>\n    void Read_(struct pollfd sock)<br \/>\n    {<br \/>\n        char buffer[BUFFERMAX];<br \/>\n        memset(buffer, 0, sizeof(buffer));<br \/>\n        int n &#061; read(sock.fd, buffer, sizeof(buffer));<br \/>\n        if (n &lt; 0)<br \/>\n        {<br \/>\n            std::cout &lt;&lt; &#034;read error&#034; &lt;&lt; std::endl;<br \/>\n            close(sock.fd);<br \/>\n            sock.fd &#061; defaultnot;<br \/>\n            \/\/close(sock.fd);<br \/>\n            \/\/sock.events &#061; non_event;<br \/>\n        }<br \/>\n        else if (n &#061;&#061; 0)<br \/>\n        {<br \/>\n            std::cout &lt;&lt; &#034;timeout&#034; &lt;&lt; std::endl;<br \/>\n            close(sock.fd);<br \/>\n            sock.fd &#061; defaultnot;<\/p>\n<p>            \/\/sock.events &#061; non_event;<br \/>\n        }<br \/>\n        else<br \/>\n        {<br \/>\n            std::string buf &#061; buffer;<br \/>\n            std::cout &lt;&lt; &#034;Client #&#034; &lt;&lt; buf &lt;&lt; std::endl;<br \/>\n        }<br \/>\n    }<br \/>\n    void Start()<br \/>\n    {<br \/>\n        \/\/ fd_set readfds;<br \/>\n        \/\/ FD_ZERO(&amp;readfds);<br \/>\n        \/\/ FD_SET(listenfd_-&gt;Fd(), &amp;readfds);<br \/>\n        read_fds[0].fd &#061; listenfd_-&gt;Fd();<br \/>\n        read_fds[0].events &#061; POLLIN; \/\/\u8bbe\u7f6e0\u53f7\u6587\u4ef6\u63cf\u8ff0\u7b26\u7684\u4e8b\u4ef6\u4e3a\u53ef\u8bfb<br \/>\n        read_fds[0].revents &#061; non_event;<br \/>\n        int timeout &#061; 3000;<br \/>\n        for (;;)          \/\/1.\u670d\u52a1\u5668\u4e3b\u5faa\u73af<br \/>\n        {<br \/>\n            \/\/ int maxfd &#061; 0;<br \/>\n            \/\/ FD_ZERO(&amp;readfds);<br \/>\n            \/\/  for (int i &#061; 0; i &lt; defaultfd; i&#043;&#043;)<br \/>\n            \/\/  {<br \/>\n            \/\/      if (rfds[i] !&#061; defaultnot)<br \/>\n            \/\/      {<br \/>\n            \/\/          FD_SET(rfds[i], &amp;readfds); \/\/ \u6dfb\u52a0\u8981\u5173\u5fc3\u4e8b\u4ef6\u5230readfds\u91cc<br \/>\n            \/\/          if (rfds[i] &gt; maxfd)<br \/>\n            \/\/              maxfd &#061; rfds[i];<br \/>\n            \/\/      }<br \/>\n            \/\/  }<br \/>\n            \/\/ \u901a\u8fc7select\u7b49\u5f85\u4e8b\u4ef6\u5c31\u7eea<\/p>\n<p>            int n &#061; poll(read_fds, defaultfd, timeout);    \/\/poll\u7b49\u5f85\u4e8b\u4ef6<br \/>\n            std::cout&lt;&lt;n&lt;&lt;std::endl;<br \/>\n            if (n &#061;&#061; 0)<br \/>\n            {<br \/>\n                \/\/ std::cout &lt;&lt; &#034;timeout &#034; &lt;&lt; std::endl;<br \/>\n                std::cout &lt;&lt; &#034;poll timeout&#034; &lt;&lt; std::endl;<br \/>\n            }<br \/>\n            else if (n &#061;&#061; -1)<br \/>\n            {<br \/>\n                std::cout &lt;&lt; &#034;poll error&#034; &lt;&lt; std::endl;<br \/>\n                exit(1);<br \/>\n            }<br \/>\n            else<br \/>\n            {<br \/>\n                \/\/ \u610f\u5473\u7740\u6709\u4e8b\u4ef6\u5c31\u7eea<br \/>\n                for (int i &#061; 0; i &lt; defaultfd; i&#043;&#043;)<br \/>\n                {<br \/>\n                    int fd &#061; read_fds[i].fd;<br \/>\n                    if (fd &#061;&#061; defaultnot)<br \/>\n                        continue;             \/\/\u8df3\u51fa\u672c\u6b21\u5faa\u73af\u4ee5\u627e\u5230\u5c31\u7eea\u7684\u4e8b\u4ef6<br \/>\n                    else<br \/>\n                    {<br \/>\n                        if (read_fds[i].revents &amp; POLLIN)<br \/>\n                        {<br \/>\n                            if (fd &#061;&#061; listenfd_-&gt;Fd())<br \/>\n                            {<br \/>\n                                Accpet_();<br \/>\n                            }<br \/>\n                            else<br \/>\n                            {<br \/>\n                                Read_(read_fds[i]);<br \/>\n                            }<br \/>\n                        }<br \/>\n                        \/\/Print_Fd();<br \/>\n                    }<br \/>\n                }<br \/>\n            }<br \/>\n        }<br \/>\n    }<br \/>\n    void Print_Fd()<br \/>\n    {<br \/>\n        for(int i &#061; 0;i&lt;defaultfd;i&#043;&#043;)<br \/>\n            if(read_fds[i].fd !&#061; defaultnot) std::cout&lt;&lt;read_fds[i].fd&lt;&lt;&#034; &#034;;<br \/>\n    }<br \/>\nprivate:<br \/>\n    Sock *listenfd_;<br \/>\n    \/\/ int rfds[defaultfd];<br \/>\n    struct pollfd read_fds[defaultfd];<br \/>\n};<\/p>\n<p>#include&lt;iostream&gt;<br \/>\n#include&#034;Poll_Server.hpp&#034;<br \/>\n\/\/#include&#034;bit_poll.hpp&#034;<\/p>\n<p>int main()<br \/>\n{<br \/>\n    Poll_Server* poll_(new Poll_Server);<br \/>\n    poll_-&gt;Init();<br \/>\n    poll_-&gt;Start();<br \/>\n    return 0;<br \/>\n} <\/p>\n<h3>3.4 I\/O\u591a\u8def\u8f6c\u63a5\u4e4bepoll<\/h3>\n<p>epoll\u521d\u8bc6\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u6309\u7167man\u624b\u518c\u7684\u8bf4\u6cd5&#xff1a;epoll\u662f\u4e3a\u4e86\u5904\u7406\u5927\u6279\u91cf\u53e5\u67c4\u800c\u505a\u4e86\u6539\u8fdb\u7684poll<\/p>\n<p>epoll\u76f8\u5173\u7cfb\u7edf\u8c03\u7528<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1069\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250419112141-6803874514b58.png\" width=\"1200\" \/>\u00a0 \u00a0 \u00a0 \u00a0\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0<img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"491\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250419112141-68038745d085d.png\" width=\"1200\" \/><\/p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb985\u6b21\uff0c\u70b9\u8d5e9\u6b21\uff0c\u6536\u85cf26\u6b21\u3002\u963b\u585eIO\uff1a\u5728\u5185\u6838\u6570\u636e\u51c6\u5907\u597d\u524d\uff0c\u7cfb\u7edf\u8c03\u7528\u4f1a\u4e00\u76f4\u7b49\u5f85\u3002\u6240\u6709\u7684\u5957\u63a5\u5b57\u9ed8\u8ba4\u90fd\u662f\u963b\u585e\u65b9\u5f0f\u975e\u963b\u585eIO\uff1a\u5982\u679c\u7cfb\u7edf\u672a\u5c06\u6570\u636e\u51c6\u5907\u597d\uff0c\u7cfb\u7edf\u8c03\u7528\u4ecd\u4f1a\u76f4\u63a5\u8fd4\u56de\uff0c\u5e76\u4e14\u8fd4\u56deEWOULDBLOCK\u9519\u8bef\u7801\u3002\u4e00\u822c\u6765\u8bb2\u5bf9\u4e8e\u4e00\u4e2a\u53ef\u80fd\u4ea7\u751f\u6570\u636e\u7684\u6587\u4ef6\u63cf\u8ff0\u7b26\u6211\u4eec\u5e0c\u671b\u5728\u4ed6\u6709\u6570\u636e\u65f6\u5c31\u5c06\u6570\u636e\u8bfb\u4e0a\u6765\uff0c\u4f46\u662f\u975e\u963b\u585eIO\u76f4\u63a5\u5c31\u8fd4\u56de\u4e86\u5e76\u4e0d\u80fd\u8fbe\u5230\u8fd9\u4e2a\u6548\u679c\uff0c\u5982\u679c\u8981\u901a\u8fc7\u975e\u963b\u585eIO\u6765\u8fbe\u5230\u8fd9\u4e2a\u76ee\u7684\uff0c\u5c31\u9700\u8981\u4e0d\u65ad\u7684\u5c1d\u8bd5\u8bfb\u5199\u6587\u4ef6\u63cf\u8ff0\u7b26\uff0c\u8fd9\u4e2a\u6539\u6210\u79f0\u4e3a\u8f6e\u8be2\uff0c\u4f46\u662f\u8f6e\u8be2\u662f\u5bf9CPU\u7684\u4e00\u79cd\u6781\u5927\u7684\u6d6a\u8d39\uff0c\u4e00\u822c\u53ea\u5728\u7279\u6b8a\u60c5\u51b5\u4e0b\u4f7f\u7528\u3002<\/p>\n","protected":false},"author":2,"featured_media":27330,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[55,58,2180,43,305,78],"topic":[],"class_list":{"0":"post-27350","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","6":"hentry","7":"category-server","8":"tag-c","9":"tag-linux","11":"tag-43","12":"tag-305","13":"tag-78"},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>[Linux\u590d\u4e60 - \u4e94\u79cdIO\u6a21\u578b] \u2014\u2014 \u963b\u585eIO\u3001\u975e\u963b\u585eIO\u3001\u4fe1\u53f7\u9a71\u52a8IO IO\u591a\u8def\u8f6c\u63a5\u3001\u5f02\u6b65IO\uff0c\u5305\u62ec\u76f8\u5173\u63a5\u53e3\u7684\u4f7f\u7528\u3001select \u3001poll\u3001epoll \u4ee5\u53ca\u901a\u8fc7\u8fd9\u4e9b\u63a5\u53e3\u5c01\u88c5\u670d\u52a1\u5668 - \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\/27350.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"[Linux\u590d\u4e60 - \u4e94\u79cdIO\u6a21\u578b] \u2014\u2014 \u963b\u585eIO\u3001\u975e\u963b\u585eIO\u3001\u4fe1\u53f7\u9a71\u52a8IO IO\u591a\u8def\u8f6c\u63a5\u3001\u5f02\u6b65IO\uff0c\u5305\u62ec\u76f8\u5173\u63a5\u53e3\u7684\u4f7f\u7528\u3001select \u3001poll\u3001epoll \u4ee5\u53ca\u901a\u8fc7\u8fd9\u4e9b\u63a5\u53e3\u5c01\u88c5\u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb985\u6b21\uff0c\u70b9\u8d5e9\u6b21\uff0c\u6536\u85cf26\u6b21\u3002\u963b\u585eIO\uff1a\u5728\u5185\u6838\u6570\u636e\u51c6\u5907\u597d\u524d\uff0c\u7cfb\u7edf\u8c03\u7528\u4f1a\u4e00\u76f4\u7b49\u5f85\u3002\u6240\u6709\u7684\u5957\u63a5\u5b57\u9ed8\u8ba4\u90fd\u662f\u963b\u585e\u65b9\u5f0f\u975e\u963b\u585eIO\uff1a\u5982\u679c\u7cfb\u7edf\u672a\u5c06\u6570\u636e\u51c6\u5907\u597d\uff0c\u7cfb\u7edf\u8c03\u7528\u4ecd\u4f1a\u76f4\u63a5\u8fd4\u56de\uff0c\u5e76\u4e14\u8fd4\u56deEWOULDBLOCK\u9519\u8bef\u7801\u3002\u4e00\u822c\u6765\u8bb2\u5bf9\u4e8e\u4e00\u4e2a\u53ef\u80fd\u4ea7\u751f\u6570\u636e\u7684\u6587\u4ef6\u63cf\u8ff0\u7b26\u6211\u4eec\u5e0c\u671b\u5728\u4ed6\u6709\u6570\u636e\u65f6\u5c31\u5c06\u6570\u636e\u8bfb\u4e0a\u6765\uff0c\u4f46\u662f\u975e\u963b\u585eIO\u76f4\u63a5\u5c31\u8fd4\u56de\u4e86\u5e76\u4e0d\u80fd\u8fbe\u5230\u8fd9\u4e2a\u6548\u679c\uff0c\u5982\u679c\u8981\u901a\u8fc7\u975e\u963b\u585eIO\u6765\u8fbe\u5230\u8fd9\u4e2a\u76ee\u7684\uff0c\u5c31\u9700\u8981\u4e0d\u65ad\u7684\u5c1d\u8bd5\u8bfb\u5199\u6587\u4ef6\u63cf\u8ff0\u7b26\uff0c\u8fd9\u4e2a\u6539\u6210\u79f0\u4e3a\u8f6e\u8be2\uff0c\u4f46\u662f\u8f6e\u8be2\u662f\u5bf9CPU\u7684\u4e00\u79cd\u6781\u5927\u7684\u6d6a\u8d39\uff0c\u4e00\u822c\u53ea\u5728\u7279\u6b8a\u60c5\u51b5\u4e0b\u4f7f\u7528\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/27350.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-19T11:21:43+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250419112134-6803873ebc5f9.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=\"6 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/27350.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/27350.html\",\"name\":\"[Linux\u590d\u4e60 - \u4e94\u79cdIO\u6a21\u578b] \u2014\u2014 \u963b\u585eIO\u3001\u975e\u963b\u585eIO\u3001\u4fe1\u53f7\u9a71\u52a8IO IO\u591a\u8def\u8f6c\u63a5\u3001\u5f02\u6b65IO\uff0c\u5305\u62ec\u76f8\u5173\u63a5\u53e3\u7684\u4f7f\u7528\u3001select \u3001poll\u3001epoll \u4ee5\u53ca\u901a\u8fc7\u8fd9\u4e9b\u63a5\u53e3\u5c01\u88c5\u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-04-19T11:21:43+00:00\",\"dateModified\":\"2025-04-19T11:21:43+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/27350.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/27350.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/27350.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"[Linux\u590d\u4e60 -- \u4e94\u79cdIO\u6a21\u578b] \u2014\u2014 \u963b\u585eIO\u3001\u975e\u963b\u585eIO\u3001\u4fe1\u53f7\u9a71\u52a8IO IO\u591a\u8def\u8f6c\u63a5\u3001\u5f02\u6b65IO\uff0c\u5305\u62ec\u76f8\u5173\u63a5\u53e3\u7684\u4f7f\u7528\u3001select \u3001poll\u3001epoll \u4ee5\u53ca\u901a\u8fc7\u8fd9\u4e9b\u63a5\u53e3\u5c01\u88c5\u670d\u52a1\u5668\"}]},{\"@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\u590d\u4e60 - \u4e94\u79cdIO\u6a21\u578b] \u2014\u2014 \u963b\u585eIO\u3001\u975e\u963b\u585eIO\u3001\u4fe1\u53f7\u9a71\u52a8IO IO\u591a\u8def\u8f6c\u63a5\u3001\u5f02\u6b65IO\uff0c\u5305\u62ec\u76f8\u5173\u63a5\u53e3\u7684\u4f7f\u7528\u3001select \u3001poll\u3001epoll \u4ee5\u53ca\u901a\u8fc7\u8fd9\u4e9b\u63a5\u53e3\u5c01\u88c5\u670d\u52a1\u5668 - \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\/27350.html","og_locale":"zh_CN","og_type":"article","og_title":"[Linux\u590d\u4e60 - \u4e94\u79cdIO\u6a21\u578b] \u2014\u2014 \u963b\u585eIO\u3001\u975e\u963b\u585eIO\u3001\u4fe1\u53f7\u9a71\u52a8IO IO\u591a\u8def\u8f6c\u63a5\u3001\u5f02\u6b65IO\uff0c\u5305\u62ec\u76f8\u5173\u63a5\u53e3\u7684\u4f7f\u7528\u3001select \u3001poll\u3001epoll \u4ee5\u53ca\u901a\u8fc7\u8fd9\u4e9b\u63a5\u53e3\u5c01\u88c5\u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb985\u6b21\uff0c\u70b9\u8d5e9\u6b21\uff0c\u6536\u85cf26\u6b21\u3002\u963b\u585eIO\uff1a\u5728\u5185\u6838\u6570\u636e\u51c6\u5907\u597d\u524d\uff0c\u7cfb\u7edf\u8c03\u7528\u4f1a\u4e00\u76f4\u7b49\u5f85\u3002\u6240\u6709\u7684\u5957\u63a5\u5b57\u9ed8\u8ba4\u90fd\u662f\u963b\u585e\u65b9\u5f0f\u975e\u963b\u585eIO\uff1a\u5982\u679c\u7cfb\u7edf\u672a\u5c06\u6570\u636e\u51c6\u5907\u597d\uff0c\u7cfb\u7edf\u8c03\u7528\u4ecd\u4f1a\u76f4\u63a5\u8fd4\u56de\uff0c\u5e76\u4e14\u8fd4\u56deEWOULDBLOCK\u9519\u8bef\u7801\u3002\u4e00\u822c\u6765\u8bb2\u5bf9\u4e8e\u4e00\u4e2a\u53ef\u80fd\u4ea7\u751f\u6570\u636e\u7684\u6587\u4ef6\u63cf\u8ff0\u7b26\u6211\u4eec\u5e0c\u671b\u5728\u4ed6\u6709\u6570\u636e\u65f6\u5c31\u5c06\u6570\u636e\u8bfb\u4e0a\u6765\uff0c\u4f46\u662f\u975e\u963b\u585eIO\u76f4\u63a5\u5c31\u8fd4\u56de\u4e86\u5e76\u4e0d\u80fd\u8fbe\u5230\u8fd9\u4e2a\u6548\u679c\uff0c\u5982\u679c\u8981\u901a\u8fc7\u975e\u963b\u585eIO\u6765\u8fbe\u5230\u8fd9\u4e2a\u76ee\u7684\uff0c\u5c31\u9700\u8981\u4e0d\u65ad\u7684\u5c1d\u8bd5\u8bfb\u5199\u6587\u4ef6\u63cf\u8ff0\u7b26\uff0c\u8fd9\u4e2a\u6539\u6210\u79f0\u4e3a\u8f6e\u8be2\uff0c\u4f46\u662f\u8f6e\u8be2\u662f\u5bf9CPU\u7684\u4e00\u79cd\u6781\u5927\u7684\u6d6a\u8d39\uff0c\u4e00\u822c\u53ea\u5728\u7279\u6b8a\u60c5\u51b5\u4e0b\u4f7f\u7528\u3002","og_url":"https:\/\/www.wsisp.com\/helps\/27350.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-04-19T11:21:43+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250419112134-6803873ebc5f9.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"6 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/27350.html","url":"https:\/\/www.wsisp.com\/helps\/27350.html","name":"[Linux\u590d\u4e60 - \u4e94\u79cdIO\u6a21\u578b] \u2014\u2014 \u963b\u585eIO\u3001\u975e\u963b\u585eIO\u3001\u4fe1\u53f7\u9a71\u52a8IO IO\u591a\u8def\u8f6c\u63a5\u3001\u5f02\u6b65IO\uff0c\u5305\u62ec\u76f8\u5173\u63a5\u53e3\u7684\u4f7f\u7528\u3001select \u3001poll\u3001epoll \u4ee5\u53ca\u901a\u8fc7\u8fd9\u4e9b\u63a5\u53e3\u5c01\u88c5\u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-04-19T11:21:43+00:00","dateModified":"2025-04-19T11:21:43+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/27350.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/27350.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/27350.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"[Linux\u590d\u4e60 -- \u4e94\u79cdIO\u6a21\u578b] \u2014\u2014 \u963b\u585eIO\u3001\u975e\u963b\u585eIO\u3001\u4fe1\u53f7\u9a71\u52a8IO IO\u591a\u8def\u8f6c\u63a5\u3001\u5f02\u6b65IO\uff0c\u5305\u62ec\u76f8\u5173\u63a5\u53e3\u7684\u4f7f\u7528\u3001select \u3001poll\u3001epoll \u4ee5\u53ca\u901a\u8fc7\u8fd9\u4e9b\u63a5\u53e3\u5c01\u88c5\u670d\u52a1\u5668"}]},{"@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\/27350","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=27350"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/27350\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/27330"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=27350"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=27350"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=27350"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=27350"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}