{"id":63616,"date":"2026-01-22T02:40:57","date_gmt":"2026-01-21T18:40:57","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/63616.html"},"modified":"2026-01-22T02:40:57","modified_gmt":"2026-01-21T18:40:57","slug":"%e3%80%8aepoll%e6%b7%b1%e5%ba%a6%e8%a7%a3%e6%9e%90%ef%bc%9a%e4%bb%8e%e5%8e%9f%e7%90%86%e5%88%b0%e4%bd%bf%e7%94%a8%ef%bc%8c%e8%a7%a3%e9%94%81linux%e9%ab%98%e5%b9%b6%e5%8f%91i-o%e7%9a%84%e6%a0%b8","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/63616.html","title":{"rendered":"\u300aepoll\u6df1\u5ea6\u89e3\u6790\uff1a\u4ece\u539f\u7406\u5230\u4f7f\u7528\uff0c\u89e3\u9501Linux\u9ad8\u5e76\u53d1I\/O\u7684\u6838\u5fc3\u80fd\u529b\uff08\u7ec8\u7bc7\uff09\u300b"},"content":{"rendered":"<p style=\"text-align:center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260121184055-69711db7a3189.gif\" \/><\/p>\n<p style=\"text-align:center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260121184055-69711db7c2e12.gif\" \/><\/p>\n<p><span style=\"color:#fe2c24\">\u524d\u5f15&#xff1a;<\/span>\u5728Linux\u7cfb\u7edf\u7684\u9ad8\u5e76\u53d1\u9886\u57df&#xff0c;I\/O\u5904\u7406\u6548\u7387\u76f4\u63a5\u51b3\u5b9a\u4e86\u670d\u52a1\u7684\u6027\u80fd\u4e0a\u9650\u3002\u5f53\u6211\u4eec\u9762\u5bf9\u6bcf\u79d2\u6570\u4e07\u751a\u81f3\u6570\u5341\u4e07\u7684\u8fde\u63a5\u8bf7\u6c42\u65f6&#xff0c;\u4f20\u7edf\u7684\u201c\u4e00\u8fde\u63a5\u4e00\u7ebf\u7a0b\u201d\u6a21\u578b\u4f1a\u56e0\u7ebf\u7a0b\u5207\u6362\u5f00\u9500\u66b4\u589e\u800c\u8fc5\u901f\u5d29\u6e83&#xff0c;\u800c\u65e9\u671f\u7684I\/O\u591a\u8def\u8f6c\u63a5\u6280\u672f\u5982select\u548cpoll&#xff0c;\u4e5f\u65e9\u5df2\u66b4\u9732\u51fa\u8eab\u6cd5\u7b28\u91cd\u7684\u77ed\u677f\u2014\u2014select\u53d7\u9650\u4e8eFD_SETSIZE\u76841024\u6587\u4ef6\u63cf\u8ff0\u7b26\u9650\u5236&#xff0c;poll\u867d\u7a81\u7834\u4e86\u6570\u91cf\u7ea6\u675f&#xff0c;\u5374\u9700\u5728\u7528\u6237\u6001\u4e0e\u5185\u6838\u6001\u95f4\u9891\u7e41\u62f7\u8d1d\u4e8b\u4ef6\u6570\u7ec4&#xff0c;\u5728\u9ad8\u5e76\u53d1\u573a\u666f\u4e0b\u6027\u80fd\u635f\u8017\u5448\u6307\u6570\u7ea7\u4e0a\u5347&#xff01;<\/p>\n<p id=\"main-toc\">\u76ee\u5f55<\/p>\n<p id=\"%E3%80%90%E4%B8%80%E3%80%91epoll%E4%BB%8B%E7%BB%8D-toc\" style=\"margin-left:40px\">\u3010\u4e00\u3011epoll\u4ecb\u7ecd<\/p>\n<p id=\"%E3%80%90%E4%BA%8C%E3%80%91%E6%8E%A5%E5%8F%A3%E4%BD%BF%E7%94%A8%E8%AF%B4%E6%98%8E-toc\" style=\"margin-left:40px\">\u3010\u4e8c\u3011\u63a5\u53e3\u4f7f\u7528\u8bf4\u660e<\/p>\n<p id=\"%E3%80%90%E4%BA%8C%E3%80%91epoll%E6%A8%A1%E5%9E%8B-toc\" style=\"margin-left:40px\">\u3010\u4e8c\u3011epoll\u6a21\u578b<\/p>\n<p id=\"%E3%80%90%E5%9B%9B%E3%80%91epoll_create-toc\" style=\"margin-left:40px\">\u3010\u56db\u3011epoll_create<\/p>\n<p id=\"%EF%BC%881%EF%BC%89%E5%87%BD%E6%95%B0%E5%8E%9F%E5%9E%8B-toc\" style=\"margin-left:120px\">&#xff08;1&#xff09;\u51fd\u6570\u539f\u578b<\/p>\n<p id=\"%EF%BC%882%EF%BC%89%E5%8F%82%E6%95%B0-toc\" style=\"margin-left:120px\">&#xff08;2&#xff09;\u53c2\u6570<\/p>\n<p id=\"%EF%BC%883%EF%BC%89%E8%BF%94%E5%9B%9E%E5%80%BC-toc\" style=\"margin-left:120px\">&#xff08;3&#xff09;\u8fd4\u56de\u503c<\/p>\n<p id=\"%E3%80%90%E4%BA%94%E3%80%91epoll_ctl-toc\" style=\"margin-left:40px\">\u3010\u4e94\u3011epoll_ctl<\/p>\n<p id=\"%EF%BC%881%EF%BC%89%E5%87%BD%E6%95%B0%E5%8E%9F%E5%9E%8B-toc\" style=\"margin-left:120px\">&#xff08;1&#xff09;\u51fd\u6570\u539f\u578b<\/p>\n<p id=\"%EF%BC%882%EF%BC%89%E5%8F%82%E6%95%B0-toc\" style=\"margin-left:120px\">&#xff08;2&#xff09;\u53c2\u6570<\/p>\n<p id=\"%EF%BC%881%EF%BC%89%E7%AC%AC%E4%B8%80%E4%B8%AA%E5%8F%82%E6%95%B0-toc\" style=\"margin-left:200px\">&#xff08;1&#xff09;\u7b2c\u4e00\u4e2a\u53c2\u6570<\/p>\n<p id=\"%EF%BC%882%EF%BC%89%E7%AC%AC%E4%BA%8C%E4%B8%AA%E5%8F%82%E6%95%B0-toc\" style=\"margin-left:200px\">&#xff08;2&#xff09;\u7b2c\u4e8c\u4e2a\u53c2\u6570<\/p>\n<p id=\"%EF%BC%883%EF%BC%89%E7%AC%AC%E4%B8%89%E4%B8%AA%E5%8F%82%E6%95%B0-toc\" style=\"margin-left:200px\">&#xff08;3&#xff09;\u7b2c\u4e09\u4e2a\u53c2\u6570<\/p>\n<p id=\"%EF%BC%884%EF%BC%89%E7%AC%AC%E5%9B%9B%E4%B8%AA%E5%8F%82%E6%95%B0-toc\" style=\"margin-left:200px\">&#xff08;4&#xff09;\u7b2c\u56db\u4e2a\u53c2\u6570<\/p>\n<p id=\"%EF%BC%883%EF%BC%89%E8%BF%94%E5%9B%9E%E5%80%BC-toc\" style=\"margin-left:120px\">&#xff08;3&#xff09;\u8fd4\u56de\u503c<\/p>\n<p id=\"%E3%80%90%E5%85%AD%E3%80%91epoll_wait-toc\" style=\"margin-left:40px\">\u3010\u516d\u3011epoll_wait<\/p>\n<p id=\"%EF%BC%881%EF%BC%89%E5%87%BD%E6%95%B0%E5%8E%9F%E5%9E%8B-toc\" style=\"margin-left:120px\">&#xff08;1&#xff09;\u51fd\u6570\u539f\u578b<\/p>\n<p id=\"%EF%BC%882%EF%BC%89%E5%8F%82%E6%95%B0-toc\" style=\"margin-left:120px\">&#xff08;2&#xff09;\u53c2\u6570<\/p>\n<p id=\"%EF%BC%881%EF%BC%89%E7%AC%AC%E4%B8%80%E4%B8%AA%E5%8F%82%E6%95%B0-toc\" style=\"margin-left:200px\">&#xff08;1&#xff09;\u7b2c\u4e00\u4e2a\u53c2\u6570<\/p>\n<p id=\"%EF%BC%882%EF%BC%89%E7%AC%AC%E4%BA%8C%E4%B8%AA%E5%8F%82%E6%95%B0-toc\" style=\"margin-left:200px\">&#xff08;2&#xff09;\u7b2c\u4e8c\u4e2a\u53c2\u6570<\/p>\n<p id=\"%EF%BC%883%EF%BC%89%E7%AC%AC%E4%B8%89%E4%B8%AA%E5%8F%82%E6%95%B0-toc\" style=\"margin-left:200px\">&#xff08;3&#xff09;\u7b2c\u4e09\u4e2a\u53c2\u6570<\/p>\n<p id=\"%EF%BC%884%EF%BC%89%E7%AC%AC%E5%9B%9B%E4%B8%AA%E5%8F%82%E6%95%B0-toc\" style=\"margin-left:200px\">&#xff08;4&#xff09;\u7b2c\u56db\u4e2a\u53c2\u6570<\/p>\n<p id=\"%EF%BC%883%EF%BC%89%E8%BF%94%E5%9B%9E%E5%80%BC-toc\" style=\"margin-left:120px\">&#xff08;3&#xff09;\u8fd4\u56de\u503c<\/p>\n<p id=\"%E3%80%90%E4%B8%83%E3%80%91epoll%E6%A8%A1%E5%9E%8B%E4%BD%BF%E7%94%A8-toc\" style=\"margin-left:40px\">\u3010\u4e03\u3011epoll\u6a21\u578b\u4f7f\u7528<\/p>\n<p id=\"%EF%BC%881%EF%BC%89%E5%B0%81%E8%A3%85epoll%E6%8E%A5%E5%8F%A3-toc\" style=\"margin-left:120px\">&#xff08;1&#xff09;\u5c01\u88c5epoll\u63a5\u53e3<\/p>\n<p id=\"%EF%BC%882%EF%BC%89%E5%8A%9F%E8%83%BD%E5%AE%9E%E7%8E%B0-toc\" style=\"margin-left:120px\">&#xff08;2&#xff09;\u529f\u80fd\u5b9e\u73b0<\/p>\n<p id=\"%E3%80%90%E5%85%AB%E3%80%91epoll%E7%9A%84%E4%B8%A4%E7%A7%8D%E5%B7%A5%E4%BD%9C%E6%A8%A1%E5%BC%8F-toc\" style=\"margin-left:40px\">\u3010\u516b\u3011epoll\u7684\u4e24\u79cd\u5de5\u4f5c\u6a21\u5f0f<\/p>\n<p id=\"%EF%BC%881%EF%BC%89LT%E6%A8%A1%E5%BC%8F%EF%BC%88%E9%BB%98%E8%AE%A4%EF%BC%89-toc\" style=\"margin-left:120px\">&#xff08;1&#xff09;LT\u6a21\u5f0f&#xff08;\u9ed8\u8ba4&#xff09;<\/p>\n<p id=\"%EF%BC%882%EF%BC%89ET%E6%A8%A1%E5%BC%8F-toc\" style=\"margin-left:120px\">&#xff08;2&#xff09;ET\u6a21\u5f0f<\/p>\n<hr id=\"hr-toc\" \/>\n<h3 id=\"%E3%80%90%E4%B8%80%E3%80%91epoll%E4%BB%8B%E7%BB%8D\" style=\"background-color:transparent\">\u3010\u4e00\u3011epoll\u4ecb\u7ecd<\/h3>\n<p>\u7528\u6765\u5173\u5fc3\u4f60\u8bbe\u7f6e\u7684\u6587\u4ef6\u63cf\u8ff0\u7b26&#xff1a;\u4e0eselect\u548cepoll\u529f\u80fd\u7c7b\u4f3c&#xff0c;\u4f46\u7ed3\u6784\u5b8c\u5168\u4e0d\u540c<\/p>\n<h3 id=\"%E3%80%90%E4%BA%8C%E3%80%91%E6%8E%A5%E5%8F%A3%E4%BD%BF%E7%94%A8%E8%AF%B4%E6%98%8E\">\u3010\u4e8c\u3011\u63a5\u53e3\u4f7f\u7528\u8bf4\u660e<\/h3>\n<p>epoll \u7684\u4f7f\u7528\u9700\u8981\u548c\u524d\u9762\u7684 select \u4e0e poll \u533a\u522b&#xff0c;\u5b83\u4e00\u822c\u60c5\u51b5\u4e0b\u7531\u4e09\u4e2a\u63a5\u53e3\u7ec4\u6210&#xff01;\u5982\u4e0b\u8bb2\u89e3&#xff1a;<\/p>\n<p>\u5934\u6587\u4ef6\u90fd\u662f:&lt;sys\/epoll.h&gt; <\/p>\n<h3 id=\"%E3%80%90%E4%BA%8C%E3%80%91epoll%E6%A8%A1%E5%9E%8B\" style=\"background-color:transparent\">\u3010\u4e8c\u3011epoll\u6a21\u578b<\/h3>\n<p>epoll \u6a21\u578b\u5176\u5b9e\u6d89\u53ca\u5230&#xff1a;<span style=\"color:#fe2c24\">\u7ea2\u9ed1\u6811&#043;\u5c31\u7eea\u961f\u5217&#043;\u56de\u8c03\u673a\u5236<\/span><\/p>\n<p>\u7ea2\u9ed1\u6811&#xff1a;\u7528\u6765\u9ad8\u6548\u7ba1\u7406\u9700\u8981\u76d1\u542c\u7684\u6587\u4ef6\u63cf\u8ff0\u7b26&#xff0c;\u8282\u70b9\u901a\u5e38\u662f\u4e00\u4e2a\u7ed3\u6784\u4f53\u7c7b\u578b<\/p>\n<p>\u5c31\u7eea\u961f\u5217&#xff1a;\u5c06\u5df2\u7ecf\u5c31\u7eea\u7684\u6587\u4ef6\u4e8b\u4ef6\u653e\u5165\u5c31\u7eea\u961f\u5217<\/p>\n<p>\u56de\u8c03\u673a\u5236&#xff1a;\u7528\u6765\u7ba1\u7406\u7ea2\u9ed1\u6811\u548c\u8fd0\u884c\u961f\u5217&#xff0c;\u4e0d\u7528\u7528\u6237\u81ea\u5df1\u64cd\u4f5c&#xff0c;\u53ea\u9700\u8981\u6dfb\u52a0\u5173\u5fc3\u7684\u6587\u4ef6\u63cf\u8ff0\u7b26\u5373\u53ef<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u6bd4\u5982&#xff1a;\u5c06\u7f51\u5361\u62ff\u5230\u7684\u6570\u636e\u4ea4\u7ed9TCP\u8fd0\u884c\u961f\u5217&#xff1b;\u8282\u70b9\u7684\u589e\u5220&#8230;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"926\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260121184055-69711db7d2314.png\" width=\"1169\" \/><\/p>\n<h3 id=\"%E3%80%90%E5%9B%9B%E3%80%91epoll_create\">\u3010\u56db\u3011epoll_create<\/h3>\n<h5 id=\"%EF%BC%881%EF%BC%89%E5%87%BD%E6%95%B0%E5%8E%9F%E5%9E%8B\">&#xff08;1&#xff09;\u51fd\u6570\u539f\u578b<\/h5>\n<p>int epoll_create(int size); <\/p>\n<h5 id=\"%EF%BC%882%EF%BC%89%E5%8F%82%E6%95%B0\">&#xff08;2&#xff09;\u53c2\u6570<\/h5>\n<p><span style=\"color:#fe2c24\">\u8bf4\u660e&#xff1a;<\/span>\u8981\u76d1\u63a7\u7684 fd \u6570\u91cf&#xff0c;\u7cfb\u7edf\u4f1a\u52a8\u6001\u8c03\u6574&#xff0c;\u53ef\u4ee5\u4efb\u610f\u4f20\u4e00\u4e2a\u6b63\u6570<\/p>\n<h5 id=\"%EF%BC%883%EF%BC%89%E8%BF%94%E5%9B%9E%E5%80%BC\">&#xff08;3&#xff09;\u8fd4\u56de\u503c<\/h5>\n<p>\u521b\u5efa\u4e00\u4e2a epoll \u6a21\u578b&#xff0c;\u5e76\u8fd4\u56de\u00a0epoll \u6a21\u578b\u5bf9\u5e94\u7684\u6587\u4ef6\u63cf\u8ff0\u7b26&#xff0c;\u7406\u89e3\u8fd4\u56de\u503c\u9700\u8981\u5148\u770b epoll \u6a21\u578b<\/p>\n<h3 id=\"%E3%80%90%E4%BA%94%E3%80%91epoll_ctl\" style=\"background-color:transparent\">\u3010\u4e94\u3011epoll_ctl<\/h3>\n<h5 id=\"%EF%BC%881%EF%BC%89%E5%87%BD%E6%95%B0%E5%8E%9F%E5%9E%8B\">&#xff08;1&#xff09;\u51fd\u6570\u539f\u578b<\/h5>\n<p>int epoll_ctl(int epfd, int op, int fd, struct epoll_event *event); <\/p>\n<h5 id=\"%EF%BC%882%EF%BC%89%E5%8F%82%E6%95%B0\">&#xff08;2&#xff09;\u53c2\u6570<\/h5>\n<h6 id=\"%EF%BC%881%EF%BC%89%E7%AC%AC%E4%B8%80%E4%B8%AA%E5%8F%82%E6%95%B0\">&#xff08;1&#xff09;\u7b2c\u4e00\u4e2a\u53c2\u6570<\/h6>\n<p><span style=\"color:#fe2c24\">\u8bf4\u660e&#xff1a;<\/span>epoll_create \u521b\u5efa\u7684 epoll \u6a21\u578b\u6587\u4ef6\u63cf\u8ff0\u7b26<\/p>\n<h6 id=\"%EF%BC%882%EF%BC%89%E7%AC%AC%E4%BA%8C%E4%B8%AA%E5%8F%82%E6%95%B0\">&#xff08;2&#xff09;\u7b2c\u4e8c\u4e2a\u53c2\u6570<\/h6>\n<p><span style=\"color:#fe2c24\">\u8bf4\u660e&#xff1a;<\/span>\u4e09\u79cd\u64cd\u4f5c\u9009\u9879<\/p>\n<ul>\n<li>EPOLL_CTL_ADD&#xff1a;\u628a fd \u52a0\u5165\u76d1\u63a7\u5217\u8868&#xff08;\u65b0\u5b89\u6392\u4efb\u52a1&#xff09;<\/li>\n<li>EPOLL_CTL_MOD&#xff1a;\u4fee\u6539\u5df2\u76d1\u63a7 fd \u7684\u4e8b\u4ef6\u7c7b\u578b&#xff08;\u8c03\u6574\u4efb\u52a1&#xff09;<\/li>\n<li>EPOLL_CTL_DEL&#xff1a;\u628a fd \u4ece\u76d1\u63a7\u5217\u8868\u79fb\u9664&#xff08;\u53d6\u6d88\u4efb\u52a1&#xff09;<\/li>\n<\/ul>\n<h6 id=\"%EF%BC%883%EF%BC%89%E7%AC%AC%E4%B8%89%E4%B8%AA%E5%8F%82%E6%95%B0\">&#xff08;3&#xff09;\u7b2c\u4e09\u4e2a\u53c2\u6570<\/h6>\n<p><span style=\"color:#fe2c24\">\u8bf4\u660e&#xff1a;<\/span>\u8981\u6dfb\u52a0\u7684\u76ee\u6807\u6587\u4ef6\u63cf\u8ff0\u7b26<\/p>\n<h6 id=\"%EF%BC%884%EF%BC%89%E7%AC%AC%E5%9B%9B%E4%B8%AA%E5%8F%82%E6%95%B0\">&#xff08;4&#xff09;\u7b2c\u56db\u4e2a\u53c2\u6570<\/h6>\n<p><span style=\"color:#fe2c24\">\u8bf4\u660e&#xff1a;<\/span>epoll_event\u7c7b\u578b\u7684\u7ed3\u6784\u4f53\u6307\u9488&#xff0c;\u5bf9\u6dfb\u52a0\u7684\u6587\u4ef6\u63cf\u8ff0\u7b26\u4f5c\u8bf4\u660e<\/p>\n<p>struct epoll_event<br \/>\n{<br \/>\n    uint32_t events;  \/\/ \u8981\u76d1\u63a7\u7684\u4e8b\u4ef6\u7c7b\u578b&#xff08;\u6bd4\u5982\u201c\u80fd\u8bfb\u4e86\u201d\u201c\u80fd\u5199\u4e86\u201d&#xff09;<br \/>\n    epoll_data_t data;\/\/ \u5173\u8054\u6570\u636e&#xff08;\u7528\u6765\u6807\u8bc6\u8fd9\u4e2afd&#xff0c;\u65b9\u4fbf\u540e\u7eed\u5904\u7406&#xff09;<br \/>\n};<\/p>\n<p>\/\/ data\u662f\u4e2a\u8054\u5408\u4f53&#xff08;\u53ef\u4ee5\u5b58\u4e0d\u540c\u7c7b\u578b\u7684\u6570\u636e&#xff09;&#xff1a;<br \/>\ntypedef union epoll_data<br \/>\n{<br \/>\n    void    *ptr;   \/\/ \u6307\u9488&#xff08;\u6bd4\u5982\u5b58fd\u5bf9\u5e94\u7684\u4e1a\u52a1\u6570\u636e&#xff09;<br \/>\n    int      fd;    \/\/ \u76f4\u63a5\u5b58fd\u672c\u8eab&#xff08;\u6700\u5e38\u7528&#xff09;<br \/>\n    uint32_t u32;   \/\/ 32\u4f4d\u6574\u6570<br \/>\n    uint64_t u64;   \/\/ 64\u4f4d\u6574\u6570&#xff08;\u6bd4\u5982\u4f4d\u56fe\u6807\u8bb0&#xff09;<br \/>\n} epoll_data_t; <\/p>\n<ul>\n<li>events\u5e38\u7528\u53d6\u503c&#xff1a;\n<ul>\n<li>EPOLLIN&#xff1a;fd \u6709\u6570\u636e\u53ef\u4ee5\u8bfb&#xff08;\u6bd4\u5982 socket \u6536\u5230\u4e86\u5ba2\u6237\u7aef\u6d88\u606f&#xff09;<\/li>\n<li>EPOLLOUT&#xff1a;fd \u53ef\u4ee5\u5199\u6570\u636e&#xff08;\u6bd4\u5982 socket \u53ef\u4ee5\u7ed9\u5ba2\u6237\u7aef\u53d1\u6d88\u606f\u4e86&#xff09;<\/li>\n<li>EPOLLERR&#xff1a;fd \u53d1\u751f\u4e86\u9519\u8bef<\/li>\n<li>\u53ef\u4ee5\u7528 \u201c\u6216\u8fd0\u7b97\u201d \u7ec4\u5408&#xff08;\u6bd4\u5982EPOLLIN | EPOLLOUT\u8868\u793a\u540c\u65f6\u76d1\u63a7\u8bfb\u5199&#xff09;<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h5 id=\"%EF%BC%883%EF%BC%89%E8%BF%94%E5%9B%9E%E5%80%BC\">&#xff08;3&#xff09;\u8fd4\u56de\u503c<\/h5>\n<p><span style=\"color:#fe2c24\">\u8bf4\u660e&#xff1a;<\/span>\u8fd4\u56de0&#xff1a;\u8bf4\u660e\u4e8b\u4ef6\u6dfb\u52a0\u6210\u529f&#xff1b;\u8fd4\u56de-1&#xff1a;errno<\/p>\n<h3 id=\"%E3%80%90%E5%85%AD%E3%80%91epoll_wait\" style=\"background-color:transparent\">\u3010\u516d\u3011epoll_wait<\/h3>\n<h5 id=\"%EF%BC%881%EF%BC%89%E5%87%BD%E6%95%B0%E5%8E%9F%E5%9E%8B\">&#xff08;1&#xff09;\u51fd\u6570\u539f\u578b<\/h5>\n<p>int epoll_wait(int epfd, struct epoll_event *events, int maxevents, int timeout); <\/p>\n<h5 id=\"%EF%BC%882%EF%BC%89%E5%8F%82%E6%95%B0\">&#xff08;2&#xff09;\u53c2\u6570<\/h5>\n<h6 id=\"%EF%BC%881%EF%BC%89%E7%AC%AC%E4%B8%80%E4%B8%AA%E5%8F%82%E6%95%B0\">&#xff08;1&#xff09;\u7b2c\u4e00\u4e2a\u53c2\u6570<\/h6>\n<p><span style=\"color:#fe2c24\">\u8bf4\u660e&#xff1a;<\/span>epoll \u6a21\u578b\u6587\u4ef6\u63cf\u8ff0\u7b26&#xff08;epoll_create\u7684\u8fd4\u56de\u503c&#xff09;<\/p>\n<h6 id=\"%EF%BC%882%EF%BC%89%E7%AC%AC%E4%BA%8C%E4%B8%AA%E5%8F%82%E6%95%B0\">&#xff08;2&#xff09;\u7b2c\u4e8c\u4e2a\u53c2\u6570<\/h6>\n<p><span style=\"color:#fe2c24\">\u8bf4\u660e&#xff1a;<\/span>epoll_event\u7c7b\u578b\u7684\u6570\u7ec4&#xff0c;\u7528\u6765\u5b58\u50a8\u4fe1\u606f&#xff08;\u5373\u5f53\u6709\u4e8b\u4ef6\u5c31\u7eea&#xff0c;\u64cd\u4f5c\u7cfb\u7edf\u81ea\u52a8\u7ed9\u4f60\u586b&#xff09;<\/p>\n<p>struct epoll_event<br \/>\n{<br \/>\n    uint32_t events;  \/\/ \u8981\u76d1\u63a7\u7684\u4e8b\u4ef6\u7c7b\u578b&#xff08;\u6bd4\u5982\u201c\u80fd\u8bfb\u4e86\u201d\u201c\u80fd\u5199\u4e86\u201d&#xff09;<br \/>\n    epoll_data_t data;\/\/ \u5173\u8054\u6570\u636e&#xff08;\u7528\u6765\u6807\u8bc6\u8fd9\u4e2afd&#xff0c;\u65b9\u4fbf\u540e\u7eed\u5904\u7406&#xff09;<br \/>\n};<\/p>\n<p>\/\/ data\u662f\u4e2a\u8054\u5408\u4f53&#xff08;\u53ef\u4ee5\u5b58\u4e0d\u540c\u7c7b\u578b\u7684\u6570\u636e&#xff09;&#xff1a;<br \/>\ntypedef union epoll_data<br \/>\n{<br \/>\n    void    *ptr;   \/\/ \u6307\u9488&#xff08;\u6bd4\u5982\u5b58fd\u5bf9\u5e94\u7684\u4e1a\u52a1\u6570\u636e&#xff09;<br \/>\n    int      fd;    \/\/ \u76f4\u63a5\u5b58fd\u672c\u8eab&#xff08;\u6700\u5e38\u7528&#xff09;<br \/>\n    uint32_t u32;   \/\/ 32\u4f4d\u6574\u6570<br \/>\n    uint64_t u64;   \/\/ 64\u4f4d\u6574\u6570&#xff08;\u6bd4\u5982\u4f4d\u56fe\u6807\u8bb0&#xff09;<br \/>\n} epoll_data_t; <\/p>\n<h6 id=\"%EF%BC%883%EF%BC%89%E7%AC%AC%E4%B8%89%E4%B8%AA%E5%8F%82%E6%95%B0\">&#xff08;3&#xff09;\u7b2c\u4e09\u4e2a\u53c2\u6570<\/h6>\n<p><span style=\"color:#fe2c24\">\u8bf4\u660e&#xff1a;<\/span>\u6700\u591a\u5173\u5fc3\u7684\u4e8b\u4ef6\u4e2a\u6570&#xff08;\u6bd4\u5982&#xff1a;\u5e94\u7528\u5c42\u7684\u6211\u6700\u591a\u53ea\u5173\u5fc32\u4e2a&#xff0c;\u5269\u4f59\u4e8b\u4ef6\u4e0b\u6b21\u4f1a\u7ee7\u7eed\u62a5\u544a\u7ed9\u4f60&#xff09;<\/p>\n<h6 id=\"%EF%BC%884%EF%BC%89%E7%AC%AC%E5%9B%9B%E4%B8%AA%E5%8F%82%E6%95%B0\">&#xff08;4&#xff09;\u7b2c\u56db\u4e2a\u53c2\u6570<\/h6>\n<p><span style=\"color:#fe2c24\">\u8bf4\u660e&#xff1a;<\/span>\u8d85\u65f6\u65f6\u95f4\u8bbe\u7f6e&#xff08;\u6beb\u79d2&#xff09;<\/p>\n<ul>\n<li>-1&#xff1a;\u4e00\u76f4\u963b\u585e&#xff0c;\u76f4\u5230\u6709\u4e8b\u4ef6\u53d1\u751f<\/li>\n<li>0&#xff1a;\u7acb\u5373\u8fd4\u56de&#xff08;\u4e0d\u7ba1\u6709\u6ca1\u6709\u4e8b\u4ef6&#xff09;<\/li>\n<li>\u6b63\u6570&#xff1a;\u6700\u591a\u7b49\u8fd9\u4e48\u4e45&#xff0c;\u6ca1\u4e8b\u4ef6\u5c31\u8d85\u65f6\u8fd4\u56de<\/li>\n<\/ul>\n<h5 id=\"%EF%BC%883%EF%BC%89%E8%BF%94%E5%9B%9E%E5%80%BC\">&#xff08;3&#xff09;\u8fd4\u56de\u503c<\/h5>\n<p><span style=\"color:#fe2c24\">\u8bf4\u660e&#xff1a;<\/span>\u89e6\u53d1\u4e8b\u4ef6\u7684 fd \u6570\u91cf<\/p>\n<p>\u8fd4\u56de0&#xff1a;\u6ca1\u6709\u4e8b\u4ef6\u5c31\u7eea<\/p>\n<p>\u8fd4\u56de&gt;0&#xff1a;\u4e8b\u4ef6\u5c31\u7eea\u6570\u91cf<\/p>\n<p>\u8fd4\u56de-1&#xff1a;\u51fa\u9519&#xff0c;\u8bbe\u7f6eerrno<\/p>\n<h3 id=\"%E3%80%90%E4%B8%83%E3%80%91epoll%E6%A8%A1%E5%9E%8B%E4%BD%BF%E7%94%A8\" style=\"background-color:transparent\">\u3010\u4e03\u3011epoll\u6a21\u578b\u4f7f\u7528<\/h3>\n<p><span style=\"color:#a2e043\">\u5982\u679c\u6709\u95ee\u9898&#xff0c;\u53ef\u4ee5\u79c1\u4fe1\u6211&#xff01;\u201c\u529f\u80fd\u5b9e\u73b0\u201d\u4e2d\u7684\u601d\u8def\u548c\u524d\u9762\u7ae0\u8282\u4e2d\u7684select\u601d\u8def\u8bb2\u89e3&#xff0c;\u4e00\u6a21\u4e00\u6837&#xff01;<\/span><\/p>\n<h5 id=\"%EF%BC%881%EF%BC%89%E5%B0%81%E8%A3%85epoll%E6%8E%A5%E5%8F%A3\">&#xff08;1&#xff09;\u5c01\u88c5epoll\u63a5\u53e3<\/h5>\n<p>\u5c01\u88c5\u4e0a\u9762\u4e09\u4e2a\u63a5\u53e3&#xff0c;\u8fd9\u91cc\u6ca1\u4ec0\u4e48\u597d\u8bf4\u7684\u3002\u58f0\u660e&#xff1a;\u91cc\u9762\u7684size\u662f\u7528\u6765\u5224\u65ad\u5f53\u524d\u5957\u63a5\u5b57\u4e2a\u6570\u7684<\/p>\n<p>#include&#034;TCP_Network.h&#034;<\/p>\n<p>#define max_num_size 10<\/p>\n<p>class Epoll<br \/>\n{<br \/>\npublic:<br \/>\n    \/\/\u521d\u59cb\u5316\u7ed3\u6784\u4f53<br \/>\n    void Install()<br \/>\n    {<br \/>\n        memset(events, 0, sizeof(events));<br \/>\n        for(int i&#061;0;i&lt;max_num_size;i&#043;&#043;)<br \/>\n        {<br \/>\n            events[i].data.fd&#061;-1;<br \/>\n        }<br \/>\n    }<br \/>\n    \/\/\u521b\u5efaepoll\u6a21\u578b<br \/>\n    const int Epoll_creat(int size)<br \/>\n    {<br \/>\n        if (size &lt;&#061; 0)<br \/>\n        {<br \/>\n            log_message(LOG_LEVEL_ERROR, __FILE__, __LINE__, &#034;epoll_create\u53c2\u6570\u975e\u6cd5:size\u5fc5\u987b&gt;0&#034;);<br \/>\n            exit(1);<br \/>\n        }<br \/>\n        \/\/\u521d\u59cb\u5316\u7ed3\u6784\u4f53<br \/>\n        Install();<\/p>\n<p>        int epfd &#061; epoll_create(size);<br \/>\n        if(epfd&#061;&#061;-1)<br \/>\n        {<br \/>\n            log_message(LOG_LEVEL_ERROR,__FILE__,__LINE__,&#034;\u9519\u8bef\u7801&#xff1a;%d,\u9519\u8bef\u4fe1\u606f&#xff1a;%s&#034;,errno,strerror(errno));<br \/>\n            exit(1);<br \/>\n        }<br \/>\n        return epfd;<br \/>\n    }<br \/>\n    \/\/\u8bbe\u7f6e\u5173\u5fc3\u4e8b\u4ef6<br \/>\n    const int Epoll_ctl(int epfd, int op, int fd, struct epoll_event *event)<br \/>\n    {<br \/>\n        \/\/\u5148\u68c0\u67e5size\u662f\u5426\u5df2\u6ee1<br \/>\n        if (op &#061;&#061; EPOLL_CTL_ADD)<br \/>\n        {<br \/>\n            if (size &gt;&#061; max_num_size)<br \/>\n            {<br \/>\n                std::cout &lt;&lt; &#034;\u4e8b\u4ef6\u6ee1\u4e86&#xff0c;\u6dfb\u52a0\u5931\u8d25&#034; &lt;&lt; std::endl;<br \/>\n                return -1;<br \/>\n            }<br \/>\n        }<br \/>\n        \/\/\u5148\u68c0\u67e5size\u662f\u5426\u4e3a\u7a7a<br \/>\n        else if (op &#061;&#061; EPOLL_CTL_DEL)<br \/>\n        {<br \/>\n            if (size &lt;&#061; 0)<br \/>\n            {<br \/>\n                std::cout &lt;&lt; &#034;\u4e8b\u4ef6\u5220\u9664\u5931\u8d25&#034; &lt;&lt; std::endl;<br \/>\n                return -1;<br \/>\n            }<br \/>\n        }<br \/>\n        int ct &#061; epoll_ctl(epfd, op, fd, event);<br \/>\n        if(ct&#061;&#061;-1)<br \/>\n        {<br \/>\n            log_message(LOG_LEVEL_ERROR,__FILE__,__LINE__,&#034;\u9519\u8bef\u7801&#xff1a;%d,\u9519\u8bef\u4fe1\u606f&#xff1a;%s&#034;,errno,strerror(errno));<br \/>\n            exit(1);<br \/>\n        }<br \/>\n        \/\/\u66f4\u65b0size<br \/>\n        if (op &#061;&#061; EPOLL_CTL_ADD)<br \/>\n        {<br \/>\n            size&#043;&#043;;<br \/>\n        }<br \/>\n        else if (op &#061;&#061; EPOLL_CTL_DEL)<br \/>\n        {<br \/>\n            size&#8211;;<br \/>\n        }<br \/>\n        return ct;<br \/>\n    }<br \/>\n    \/\/\u6536\u96c6\u5c31\u7eea\u4e8b\u4ef6<br \/>\n    const int Epoll_wait(int epfd, int maxevents, int timeout)<br \/>\n    {<br \/>\n        int wa &#061; epoll_wait(epfd, events, maxevents, timeout);<br \/>\n        if(wa&#061;&#061;-1)<br \/>\n        {<br \/>\n            log_message(LOG_LEVEL_ERROR,__FILE__,__LINE__,&#034;\u9519\u8bef\u7801&#xff1a;%d,\u9519\u8bef\u4fe1\u606f&#xff1a;%s&#034;,errno,strerror(errno));<br \/>\n        }<br \/>\n        return wa;<br \/>\n    }<br \/>\n    \/\/\u8fd4\u56de\u4fe1\u606f<br \/>\n    struct epoll_event* Message()<br \/>\n    {<br \/>\n        return events;<br \/>\n    }<\/p>\n<p>private:<br \/>\n    \/\/\u5b58\u50a8\u4fe1\u606f\u7684\u7ed3\u6784\u4f53<br \/>\n    struct epoll_event events[max_num_size];<br \/>\n    \/\/\u5173\u5fc3\u7684\u4e8b\u4ef6\u4e2a\u6570<br \/>\n    int size &#061;0;<br \/>\n}; <\/p>\n<h5 id=\"%EF%BC%882%EF%BC%89%E5%8A%9F%E8%83%BD%E5%AE%9E%E7%8E%B0\">&#xff08;2&#xff09;\u529f\u80fd\u5b9e\u73b0<\/h5>\n<p>epoll\u4e0epoll\u3001select\u7684\u529f\u80fd\u5b9e\u73b0\u601d\u8def\u90fd\u662f\u4e00\u6837\u7684&#xff0c;\u53ea\u9700\u8981\u77e5\u9053epoll\u7684\u4e09\u4e2a\u63a5\u53e3\u7684\u529f\u80fd&#xff1a;<\/p>\n<p><span style=\"color:#fe2c24\">epoll_create<\/span>&#xff1a;\u521b\u5efa\u4e00\u4e2aepoll\u6a21\u578b<\/p>\n<p><span style=\"color:#fe2c24\">epoll_ctl<\/span>&#xff1a;\u5bf9epoll\u6a21\u578b\u8fdb\u884c\u64cd\u4f5c&#xff08;\u589e\u5220&#xff09;<\/p>\n<p><span style=\"color:#fe2c24\">epoll_wait<\/span>&#xff1a;\u8fd4\u56de\u5c31\u7eea\u4e8b\u4ef6<\/p>\n<p>\u6838\u5fc3\u601d\u8def&#xff1a;\u5148\u521b\u5efa\u2014&gt;\u518d\u6dfb\u52a0\u5957\u63a5\u5b57\u2014&gt;\u4e8b\u4ef6\u5c31\u7eea\u5c31\u8fdb\u5165\u4efb\u52a1\u51fd\u6570\u2014&gt;listen\u5957\u63a5\u5b57\u8fd8\u662frecv\u8fdb\u884c\u5224\u65ad<\/p>\n<p>#include &#034;Epoll.h&#034;<\/p>\n<p>class Media<br \/>\n{<br \/>\npublic:<br \/>\n    void Inital()<br \/>\n    {<br \/>\n        _S.Socket();<br \/>\n        _S.Bind();<br \/>\n        _S.Listen();<br \/>\n    }<br \/>\n    void Recv(int fd, int epfd)<br \/>\n    {<br \/>\n        char buffer[1024] &#061; {0};<br \/>\n        ssize_t d &#061; recv(fd, buffer, sizeof(buffer) &#8211; 1, 0);<br \/>\n        if (d &gt; 0)<br \/>\n        {<br \/>\n            buffer[d] &#061; 0;<br \/>\n            std::cout &lt;&lt; &#034;\u5ba2\u6237\u7aef\u53d1\u9001\u4e86\u6570\u636e:&#034;;<br \/>\n            std::cout &lt;&lt; buffer &lt;&lt; std::endl;<br \/>\n        }<br \/>\n        else if (d &#061;&#061; 0)<br \/>\n        {<br \/>\n            std::cout &lt;&lt; &#034;\u5173\u95ed\u4e86\u6587\u4ef6\u63cf\u8ff0\u7b26:&#034; &lt;&lt; fd &lt;&lt; std::endl;<br \/>\n            \/\/ \u5bf9\u65b9\u65ad\u5f00\u4e86\u8fde\u63a5<br \/>\n            _E.Epoll_ctl(epfd, EPOLL_CTL_DEL, fd, nullptr);<br \/>\n            \/\/ \u5173\u95ed\u5f53\u524d\u7684\u6587\u4ef6\u63cf\u8ff0\u7b26<br \/>\n            close(fd);<br \/>\n        }<br \/>\n        else<br \/>\n        {<br \/>\n            \/\/ \u8bfb\u53d6\u9519\u8bef<br \/>\n            _E.Epoll_ctl(epfd, EPOLL_CTL_DEL, fd, nullptr);<br \/>\n            close(fd);<br \/>\n            \/\/ \u5173\u95ed\u5f53\u524d\u7684\u6587\u4ef6\u63cf\u8ff0\u7b26<\/p>\n<p>        }<br \/>\n    }<br \/>\n    \/\/ \u5904\u7406\u4e8b\u4ef6<br \/>\n    void Handle(int epfd, int wa)<br \/>\n    {<br \/>\n        \/\/ \u83b7\u53d6\u51c6\u5907\u5c31\u7eea\u7684\u4e8b\u4ef6<br \/>\n        struct epoll_event *events &#061; _E.Message();<br \/>\n        \/\/ \u904d\u5386\u4e8b\u4ef6<br \/>\n        for (int i &#061; 0; i &lt; wa; i&#043;&#043;)<br \/>\n        {<br \/>\n            if (events[i].data.fd &#061;&#061; -1)<br \/>\n                continue;<br \/>\n            if (events[i].data.fd &#061;&#061; _S.Fd())<br \/>\n            {<br \/>\n                std::cout&lt;&lt;&#034;Accept&#034;&lt;&lt;std::endl;<br \/>\n                int d &#061; _S.Accept();<br \/>\n                \/\/ \u6dfb\u52a0\u8bfb\u7aef\u4e8b\u4ef6<br \/>\n                struct epoll_event v;<br \/>\n                v.data.fd &#061; d;<br \/>\n                v.events &#061; EPOLLIN;<br \/>\n                int ctl &#061; _E.Epoll_ctl(epfd, EPOLL_CTL_ADD, d, &amp;v);<br \/>\n                if (ctl &#061;&#061; 0)<br \/>\n                {<br \/>\n                    std::cout &lt;&lt; &#034;\u4e8b\u4ef6:&#034; &lt;&lt; d &lt;&lt; &#034;\u6dfb\u52a0\u6210\u529f&#034; &lt;&lt; std::endl;<br \/>\n                }<br \/>\n            }<br \/>\n            else if (events[i].events &#061;&#061; EPOLLIN) \/\/ \u8bfb\u53d6\u6570\u636e<br \/>\n            {<br \/>\n                std::cout&lt;&lt;&#034;Recv&#034;&lt;&lt;std::endl;<br \/>\n                Recv(events[i].data.fd, epfd);<br \/>\n            }<br \/>\n            \/\/ \u5199\u7aef<br \/>\n            \/\/ \u76d1\u542c<br \/>\n        }<br \/>\n    }<br \/>\n    \/\/ \u5173\u5fc3\u4e8b\u4ef6<br \/>\n    void Install()<br \/>\n    {<br \/>\n        \/\/ \u521b\u5efaepoll\u6a21\u578b<br \/>\n        const int epfd &#061; _E.Epoll_creat(max_num_size);<\/p>\n<p>        \/\/ \u5c06listen\u5957\u63a5\u5b57\u6dfb\u52a0\u8fdbepoll\u6a21\u578b<br \/>\n        int fd &#061; _S.Fd();<\/p>\n<p>        struct epoll_event v;<br \/>\n        v.data.fd &#061; fd;<br \/>\n        v.events &#061; EPOLLIN;<br \/>\n        int ctl &#061; _E.Epoll_ctl(epfd, EPOLL_CTL_ADD, fd, &amp;v);<br \/>\n        if (ctl &#061;&#061; 0)<br \/>\n        {<br \/>\n            std::cout &lt;&lt; &#034;\u4e8b\u4ef6:&#034; &lt;&lt; fd &lt;&lt; &#034;\u6dfb\u52a0\u6210\u529f&#034; &lt;&lt; std::endl;<br \/>\n        }<\/p>\n<p>        for (;;)<br \/>\n        {<br \/>\n            \/\/ \u7b49\u5f85\u4e8b\u4ef6<br \/>\n            int wa &#061; _E.Epoll_wait(epfd, max_num_size, 2000);<br \/>\n            switch (wa)<br \/>\n            {<\/p>\n<p>                case 0:<br \/>\n                {<br \/>\n                    std::cout &lt;&lt; &#034;\u6682\u65f6\u6ca1\u6709\u4e8b\u4ef6&#8230;.HHHHHHH&#034; &lt;&lt; std::endl;<br \/>\n                    continue;<br \/>\n                }<br \/>\n                case -1:<br \/>\n                {<br \/>\n                    if (errno !&#061; EINTR)<br \/>\n                    {<br \/>\n                        std::cout &lt;&lt; &#034;Epoll_wait is fatal errno&#034; &lt;&lt; std::endl;<br \/>\n                    }<br \/>\n                    break;<br \/>\n                }<br \/>\n                default:<br \/>\n                {<br \/>\n                    Handle(epfd, wa);<br \/>\n                }<br \/>\n            }<br \/>\n        }<br \/>\n    }<\/p>\n<p>private:<br \/>\n    Server _S;<br \/>\n    Epoll _E;<br \/>\n}; <\/p>\n<h3 id=\"%E3%80%90%E5%85%AB%E3%80%91epoll%E7%9A%84%E4%B8%A4%E7%A7%8D%E5%B7%A5%E4%BD%9C%E6%A8%A1%E5%BC%8F\">\u3010\u516b\u3011epoll\u7684\u4e24\u79cd\u5de5\u4f5c\u6a21\u5f0f<\/h3>\n<h5 id=\"%EF%BC%881%EF%BC%89LT%E6%A8%A1%E5%BC%8F%EF%BC%88%E9%BB%98%E8%AE%A4%EF%BC%89\" style=\"background-color:transparent\">&#xff08;1&#xff09;LT\u6a21\u5f0f&#xff08;\u9ed8\u8ba4&#xff09;<\/h5>\n<p><span style=\"color:#fe2c24\">\u8bf4\u660e&#xff1a;<\/span>\u53ea\u8981\u76ee\u6807\u5957\u63a5\u5b57&#xff08;fd&#xff09;\u5904\u4e8e \u201c\u6709\u4e8b\u4ef6\u53ef\u5904\u7406\u201d \u7684\u72b6\u6001&#xff0c;<span style=\"color:#956fe7\">\u5c31\u4f1a\u4e00\u76f4\u901a\u77e5\u4f60<\/span><\/p>\n<p><span style=\"color:#fe2c24\">\u7279\u70b9&#xff1a;<\/span>\u5b89\u5168\u3001\u903b\u8f91\u7b80\u5355\u3001\u4f46\u662f\u91cd\u590d\u63d0\u9192\u540c\u4e00\u4e2a\u5957\u63a5\u5b57\u6548\u7387\u4f4e&#xff0c;<span style=\"color:#956fe7\">\u4e0d\u5f3a\u5236\u642d\u914d\u975e\u963b\u585eIO<\/span><\/p>\n<h5 id=\"%EF%BC%882%EF%BC%89ET%E6%A8%A1%E5%BC%8F\">&#xff08;2&#xff09;ET\u6a21\u5f0f<\/h5>\n<p><span style=\"color:#fe2c24\">\u8bf4\u660e&#xff1a;<\/span>\u53ea\u8981\u76ee\u6807\u5957\u63a5\u5b57&#xff08;fd&#xff09;\u72b6\u6001\u53d1\u9001\u53d8\u5316\u65f6&#xff0c;\u624d\u4f1a\u901a\u77e5\u4f60&#xff0c;<span style=\"color:#956fe7\">\u4e14\u53ea\u901a\u77e5\u4e00\u6b21<\/span><\/p>\n<p><span style=\"color:#fe2c24\">\u7279\u70b9&#xff1a;<\/span>\u53ea\u901a\u77e5\u4e00\u6b21&#xff0c;\u51cf\u5c11\u4e0d\u5fc5\u8981\u7684\u89e6\u53d1&#xff0c;\u6548\u7387\u6781\u9ad8&#xff0c;\u4f46\u662f\u9700\u8981\u4e00\u6b21\u6027\u8bfb\u5b8c\u6570\u636e&#xff0c;<span style=\"color:#956fe7\">\u5fc5\u987b\u642d\u914d\u975e\u963b\u585eIO<\/span><\/p>\n<p style=\"text-align:center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260121184056-69711db849aa4.gif\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u5f15&#xff1a;\u5728Linux\u7cfb\u7edf\u7684\u9ad8\u5e76\u53d1\u9886\u57df&#xff0c;I\/O\u5904\u7406\u6548\u7387\u76f4\u63a5\u51b3\u5b9a\u4e86\u670d\u52a1\u7684\u6027\u80fd\u4e0a\u9650\u3002\u5f53\u6211\u4eec\u9762\u5bf9\u6bcf\u79d2\u6570\u4e07\u751a\u81f3\u6570\u5341\u4e07\u7684\u8fde\u63a5\u8bf7\u6c42\u65f6&#xff0c;\u4f20\u7edf\u7684\u201c\u4e00\u8fde\u63a5\u4e00\u7ebf\u7a0b\u201d\u6a21\u578b\u4f1a\u56e0\u7ebf\u7a0b\u5207\u6362\u5f00\u9500\u66b4\u589e\u800c\u8fc5\u901f\u5d29\u6e83&#xff0c;\u800c\u65e9\u671f\u7684I\/O\u591a\u8def\u8f6c\u63a5\u6280\u672f\u5982select\u548cpoll&#xff0c;\u4e5f\u65e9\u5df2\u66b4\u9732\u51fa\u8eab\u6cd5\u7b28\u91cd\u7684\u77ed\u677f\u2014\u2014select\u53d7\u9650\u4e8eFD_SETSIZE\u76841024\u6587\u4ef6\u63cf\u8ff0\u7b26\u9650\u5236&#xff0c;poll\u867d\u7a81\u7834\u4e86\u6570\u91cf\u7ea6\u675f&#xff0c;\u5374\u9700\u5728\u7528\u6237\u6001\u4e0e\u5185\u6838\u6001\u95f4\u9891\u7e41\u62f7\u8d1d\u4e8b\u4ef6<\/p>\n","protected":false},"author":2,"featured_media":63612,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[58,43,78,44],"topic":[],"class_list":["post-63616","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-linux","tag-43","tag-78","tag-44"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u300aepoll\u6df1\u5ea6\u89e3\u6790\uff1a\u4ece\u539f\u7406\u5230\u4f7f\u7528\uff0c\u89e3\u9501Linux\u9ad8\u5e76\u53d1I\/O\u7684\u6838\u5fc3\u80fd\u529b\uff08\u7ec8\u7bc7\uff09\u300b - \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\/63616.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u300aepoll\u6df1\u5ea6\u89e3\u6790\uff1a\u4ece\u539f\u7406\u5230\u4f7f\u7528\uff0c\u89e3\u9501Linux\u9ad8\u5e76\u53d1I\/O\u7684\u6838\u5fc3\u80fd\u529b\uff08\u7ec8\u7bc7\uff09\u300b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u524d\u5f15&#xff1a;\u5728Linux\u7cfb\u7edf\u7684\u9ad8\u5e76\u53d1\u9886\u57df&#xff0c;I\/O\u5904\u7406\u6548\u7387\u76f4\u63a5\u51b3\u5b9a\u4e86\u670d\u52a1\u7684\u6027\u80fd\u4e0a\u9650\u3002\u5f53\u6211\u4eec\u9762\u5bf9\u6bcf\u79d2\u6570\u4e07\u751a\u81f3\u6570\u5341\u4e07\u7684\u8fde\u63a5\u8bf7\u6c42\u65f6&#xff0c;\u4f20\u7edf\u7684\u201c\u4e00\u8fde\u63a5\u4e00\u7ebf\u7a0b\u201d\u6a21\u578b\u4f1a\u56e0\u7ebf\u7a0b\u5207\u6362\u5f00\u9500\u66b4\u589e\u800c\u8fc5\u901f\u5d29\u6e83&#xff0c;\u800c\u65e9\u671f\u7684I\/O\u591a\u8def\u8f6c\u63a5\u6280\u672f\u5982select\u548cpoll&#xff0c;\u4e5f\u65e9\u5df2\u66b4\u9732\u51fa\u8eab\u6cd5\u7b28\u91cd\u7684\u77ed\u677f\u2014\u2014select\u53d7\u9650\u4e8eFD_SETSIZE\u76841024\u6587\u4ef6\u63cf\u8ff0\u7b26\u9650\u5236&#xff0c;poll\u867d\u7a81\u7834\u4e86\u6570\u91cf\u7ea6\u675f&#xff0c;\u5374\u9700\u5728\u7528\u6237\u6001\u4e0e\u5185\u6838\u6001\u95f4\u9891\u7e41\u62f7\u8d1d\u4e8b\u4ef6\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/63616.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-01-21T18:40:57+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260121184055-69711db7a3189.gif\" \/>\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=\"5 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/63616.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/63616.html\",\"name\":\"\u300aepoll\u6df1\u5ea6\u89e3\u6790\uff1a\u4ece\u539f\u7406\u5230\u4f7f\u7528\uff0c\u89e3\u9501Linux\u9ad8\u5e76\u53d1I\/O\u7684\u6838\u5fc3\u80fd\u529b\uff08\u7ec8\u7bc7\uff09\u300b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-01-21T18:40:57+00:00\",\"dateModified\":\"2026-01-21T18:40:57+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/63616.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/63616.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/63616.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u300aepoll\u6df1\u5ea6\u89e3\u6790\uff1a\u4ece\u539f\u7406\u5230\u4f7f\u7528\uff0c\u89e3\u9501Linux\u9ad8\u5e76\u53d1I\/O\u7684\u6838\u5fc3\u80fd\u529b\uff08\u7ec8\u7bc7\uff09\u300b\"}]},{\"@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":"\u300aepoll\u6df1\u5ea6\u89e3\u6790\uff1a\u4ece\u539f\u7406\u5230\u4f7f\u7528\uff0c\u89e3\u9501Linux\u9ad8\u5e76\u53d1I\/O\u7684\u6838\u5fc3\u80fd\u529b\uff08\u7ec8\u7bc7\uff09\u300b - \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\/63616.html","og_locale":"zh_CN","og_type":"article","og_title":"\u300aepoll\u6df1\u5ea6\u89e3\u6790\uff1a\u4ece\u539f\u7406\u5230\u4f7f\u7528\uff0c\u89e3\u9501Linux\u9ad8\u5e76\u53d1I\/O\u7684\u6838\u5fc3\u80fd\u529b\uff08\u7ec8\u7bc7\uff09\u300b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u524d\u5f15&#xff1a;\u5728Linux\u7cfb\u7edf\u7684\u9ad8\u5e76\u53d1\u9886\u57df&#xff0c;I\/O\u5904\u7406\u6548\u7387\u76f4\u63a5\u51b3\u5b9a\u4e86\u670d\u52a1\u7684\u6027\u80fd\u4e0a\u9650\u3002\u5f53\u6211\u4eec\u9762\u5bf9\u6bcf\u79d2\u6570\u4e07\u751a\u81f3\u6570\u5341\u4e07\u7684\u8fde\u63a5\u8bf7\u6c42\u65f6&#xff0c;\u4f20\u7edf\u7684\u201c\u4e00\u8fde\u63a5\u4e00\u7ebf\u7a0b\u201d\u6a21\u578b\u4f1a\u56e0\u7ebf\u7a0b\u5207\u6362\u5f00\u9500\u66b4\u589e\u800c\u8fc5\u901f\u5d29\u6e83&#xff0c;\u800c\u65e9\u671f\u7684I\/O\u591a\u8def\u8f6c\u63a5\u6280\u672f\u5982select\u548cpoll&#xff0c;\u4e5f\u65e9\u5df2\u66b4\u9732\u51fa\u8eab\u6cd5\u7b28\u91cd\u7684\u77ed\u677f\u2014\u2014select\u53d7\u9650\u4e8eFD_SETSIZE\u76841024\u6587\u4ef6\u63cf\u8ff0\u7b26\u9650\u5236&#xff0c;poll\u867d\u7a81\u7834\u4e86\u6570\u91cf\u7ea6\u675f&#xff0c;\u5374\u9700\u5728\u7528\u6237\u6001\u4e0e\u5185\u6838\u6001\u95f4\u9891\u7e41\u62f7\u8d1d\u4e8b\u4ef6","og_url":"https:\/\/www.wsisp.com\/helps\/63616.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-01-21T18:40:57+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/01\/20260121184055-69711db7a3189.gif"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"5 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/63616.html","url":"https:\/\/www.wsisp.com\/helps\/63616.html","name":"\u300aepoll\u6df1\u5ea6\u89e3\u6790\uff1a\u4ece\u539f\u7406\u5230\u4f7f\u7528\uff0c\u89e3\u9501Linux\u9ad8\u5e76\u53d1I\/O\u7684\u6838\u5fc3\u80fd\u529b\uff08\u7ec8\u7bc7\uff09\u300b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-01-21T18:40:57+00:00","dateModified":"2026-01-21T18:40:57+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/63616.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/63616.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/63616.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u300aepoll\u6df1\u5ea6\u89e3\u6790\uff1a\u4ece\u539f\u7406\u5230\u4f7f\u7528\uff0c\u89e3\u9501Linux\u9ad8\u5e76\u53d1I\/O\u7684\u6838\u5fc3\u80fd\u529b\uff08\u7ec8\u7bc7\uff09\u300b"}]},{"@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\/63616","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=63616"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/63616\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/63612"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=63616"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=63616"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=63616"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=63616"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}