{"id":18428,"date":"2023-09-05T12:04:13","date_gmt":"2023-09-05T04:04:13","guid":{"rendered":"https:\/\/www.techphant.cn\/?p=18428"},"modified":"2023-09-05T12:04:13","modified_gmt":"2023-09-05T04:04:13","slug":"dlfyiyn","status":"publish","type":"post","link":"https:\/\/www.techphant.cn\/blog\/18428.html","title":{"rendered":"\u591a\u8def\u590d\u7528IO\u4e0eNIO"},"content":{"rendered":"
\u591a\u8def\u590d\u7528IO\uff08Multiplexing I\/O\uff09\u548cNIO\uff08Non-blocking I\/O\uff09\u662f\u975e\u5e38\u91cd\u8981\u7684\u7f16\u7a0b\u6280\u672f\uff0c\u5b83\u4eec\u5728\u5e94\u7528\u7a0b\u5e8f\u7684\u5f00\u53d1\u4e2d\u53d1\u6325\u7740\u91cd\u8981\u7684\u4f5c\u7528\u3002\u591a\u8def\u590d\u7528IO\u548cNIO\u7684\u529f\u80fd\u76f8\u4f3c\uff0c\u4f46\u5b83\u4eec\u4e5f\u6709\u4e00\u4e9b\u663e\u8457\u7684\u4e0d\u540c\u4e4b\u5904\u3002\u672c\u6587\u5c06\u6df1\u5165\u63a2\u8ba8\u591a\u8def\u590d\u7528IO\u548cNIO\u7684\u539f\u7406\uff0c\u4ee5\u53ca\u5b83\u4eec\u4e4b\u95f4\u7684\u5173\u7cfb\u548c\u533a\u522b\u3002<\/p>\n
\u591a\u8def\u590d\u7528IO\u662f\u4e00\u79cdI\/O\u590d\u7528\u6280\u672f\uff0c\u53ef\u4ee5\u540c\u65f6\u5904\u7406\u591a\u4e2aI\/O\u64cd\u4f5c\uff0c\u4ece\u800c\u63d0\u9ad8\u7a0b\u5e8f\u7684\u6027\u80fd\u548c\u6548\u7387\u3002\u5b83\u901a\u8fc7\u4e00\u4e2a\u4e3b\u5faa\u73af\u6765\u76d1\u63a7\u591a\u4e2aI\/O\u64cd\u4f5c\uff0c\u5e76\u5728\u6536\u5230I\/O\u4e8b\u4ef6\u65f6\u7acb\u5373\u54cd\u5e94\u3002\u591a\u8def\u590d\u7528IO\u7684\u4e3b\u8981\u5b9e\u73b0\u6709select\uff08Unix\uff09\u3001poll\uff08Unix\uff09\u548cepoll\uff08Linux\uff09\u3002<\/p>\n
Select\u662f\u6700\u53e4\u8001\u7684\u591a\u8def\u590d\u7528IO\u6280\u672f\uff0c\u5b83\u53ef\u4ee5\u540c\u65f6\u76d1\u63a7\u591a\u4e2aI\/O\u64cd\u4f5c\uff0c\u5e76\u5728\u6536\u5230I\/O\u4e8b\u4ef6\u65f6\u7acb\u5373\u54cd\u5e94\u3002\u5b83\u7684\u5de5\u4f5c\u539f\u7406\u662f\uff0c\u5f53\u4e00\u4e2aI\/O\u64cd\u4f5c\u53d1\u751f\u65f6\uff0c\u5b83\u4f1a\u5c06\u8be5I\/O\u64cd\u4f5c\u653e\u5165\u4e00\u4e2a\u201c\u5c31\u7eea\u201d\u96c6\u5408\u4e2d\uff0c\u7136\u540e\u7a0b\u5e8f\u4f1a\u4e0d\u65ad\u67e5\u8be2\u8be5\u96c6\u5408\uff0c\u4ee5\u68c0\u6d4b\u662f\u5426\u6709\u65b0\u7684I\/O\u64cd\u4f5c\u53d1\u751f\u3002<\/p>\n
Poll\u662fselect\u7684\u6539\u8fdb\u7248\u672c\uff0c\u5b83\u7684\u5de5\u4f5c\u539f\u7406\u4e0eselect\u7c7b\u4f3c\uff0c\u4f46\u5176\u5b9e\u73b0\u65b9\u5f0f\u66f4\u52a0\u9ad8\u6548\u3002\u5b83\u53ef\u4ee5\u5904\u7406\u66f4\u591a\u7684I\/O\u4e8b\u4ef6\uff0c\u5e76\u4e14\u4e0d\u4f1a\u53d7\u5230select\u7684\u6700\u5927\u76d1\u63a7\u6570\u91cf\u7684\u9650\u5236\u3002<\/p>\n
Epoll\u662fLinux\u4e0b\u7684\u591a\u8def\u590d\u7528IO\u6280\u672f\uff0c\u5b83\u6709\u7740\u66f4\u9ad8\u7684\u6027\u80fd\u548c\u66f4\u591a\u7684\u529f\u80fd\u3002\u5b83\u53ef\u4ee5\u5904\u7406\u66f4\u591a\u7684I\/O\u4e8b\u4ef6\uff0c\u5e76\u4e14\u4e0d\u4f1a\u53d7\u5230select\u548cpoll\u7684\u6700\u5927\u76d1\u63a7\u6570\u91cf\u7684\u9650\u5236\u3002<\/p>\n
NIO\uff08Non-blocking I\/O\uff09\u662f\u4e00\u79cd\u975e\u963b\u585eI\/O\u6280\u672f\uff0c\u5b83\u53ef\u4ee5\u63d0\u9ad8\u7a0b\u5e8f\u7684\u6027\u80fd\u548c\u6548\u7387\u3002\u5b83\u7684\u5de5\u4f5c\u539f\u7406\u662f\uff0c\u5f53\u4e00\u4e2aI\/O\u64cd\u4f5c\u53d1\u751f\u65f6\uff0c\u5b83\u4f1a\u7acb\u5373\u8fd4\u56de\uff0c\u800c\u4e0d\u4f1a\u963b\u585e\u7a0b\u5e8f\u7684\u6267\u884c\u3002NIO\u7684\u4e3b\u8981\u5b9e\u73b0\u6709Java NIO\u3001Netty\u548cZeroMQ\u3002<\/p>\n
Java NIO\u662fJava\u8bed\u8a00\u4e2d\u7684NIO\u5b9e\u73b0\uff0c\u5b83\u53ef\u4ee5\u66f4\u9ad8\u6548\u5730\u5904\u7406I\/O\u64cd\u4f5c\uff0c\u5e76\u4e14\u4e0d\u4f1a\u963b\u585e\u7a0b\u5e8f\u7684\u6267\u884c\u3002\u5b83\u7684\u5de5\u4f5c\u539f\u7406\u662f\uff0c\u5f53\u4e00\u4e2aI\/O\u64cd\u4f5c\u53d1\u751f\u65f6\uff0c\u5b83\u4f1a\u7acb\u5373\u8fd4\u56de\uff0c\u800c\u4e0d\u4f1a\u963b\u585e\u7a0b\u5e8f\u7684\u6267\u884c\u3002<\/p>\n
Netty\u662f\u4e00\u4e2a\u57fa\u4e8eNIO\u7684\u7f51\u7edc\u5e94\u7528\u6846\u67b6\uff0c\u5b83\u53ef\u4ee5\u66f4\u9ad8\u6548\u5730\u5904\u7406\u7f51\u7edcI\/O\u64cd\u4f5c\uff0c\u5e76\u4e14\u4e0d\u4f1a\u963b\u585e\u7a0b\u5e8f\u7684\u6267\u884c\u3002\u5b83\u7684\u5de5\u4f5c\u539f\u7406\u662f\uff0c\u5f53\u4e00\u4e2aI\/O\u64cd\u4f5c\u53d1\u751f\u65f6\uff0c\u5b83\u4f1a\u7acb\u5373\u8fd4\u56de\uff0c\u800c\u4e0d\u4f1a\u963b\u585e\u7a0b\u5e8f\u7684\u6267\u884c\u3002<\/p>\n
ZeroMQ\u662f\u4e00\u4e2a\u57fa\u4e8eNIO\u7684\u6d88\u606f\u961f\u5217\u6846\u67b6\uff0c\u5b83\u53ef\u4ee5\u66f4\u9ad8\u6548\u5730\u5904\u7406\u6d88\u606fI\/O\u64cd\u4f5c\uff0c\u5e76\u4e14\u4e0d\u4f1a\u963b\u585e\u7a0b\u5e8f\u7684\u6267\u884c\u3002\u5b83\u7684\u5de5\u4f5c\u539f\u7406\u662f\uff0c\u5f53\u4e00\u4e2aI\/O\u64cd\u4f5c\u53d1\u751f\u65f6\uff0c\u5b83\u4f1a\u7acb\u5373\u8fd4\u56de\uff0c\u800c\u4e0d\u4f1a\u963b\u585e\u7a0b\u5e8f\u7684\u6267\u884c\u3002<\/p>\n
\u591a\u8def\u590d\u7528IO\u548cNIO\u662f\u975e\u5e38\u91cd\u8981\u7684\u7f16\u7a0b\u6280\u672f\uff0c\u5b83\u4eec\u53ef\u4ee5\u63d0\u9ad8\u7a0b\u5e8f\u7684\u6027\u80fd\u548c\u6548\u7387\u3002\u591a\u8def\u590d\u7528IO\u7684\u4e3b\u8981\u5b9e\u73b0\u6709select\uff0cpoll\u548cepoll\uff0c\u800cNIO\u7684\u4e3b\u8981\u5b9e\u73b0\u6709Java NIO\uff0cNetty\u548cZeroMQ\u3002\u867d\u7136\u5b83\u4eec\u7684\u529f\u80fd\u76f8\u4f3c\uff0c\u4f46\u5b83\u4eec\u4e4b\u95f4\u4e5f\u6709\u4e00\u4e9b\u663e\u8457\u7684\u4e0d\u540c\u4e4b\u5904\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"
\u591a\u8def\u590d\u7528IO\uff08MultiplexingI\/O\uff09\u548cNIO\uff08Non-blockingI\/O\uff09\u662f\u975e\u5e38\u91cd\u8981\u7684\u7f16\u7a0b\u6280\u672f\uff0c\u5b83\u4eec\u5728\u5e94\u7528\u7a0b\u5e8f\u7684\u5f00\u53d1\u4e2d\u53d1\u6325\u7740\u91cd\u8981\u7684\u4f5c\u7528\u3002\u591a\u8def<\/p>\n","protected":false},"author":1,"featured_media":3671,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"default","ast-global-header-display":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","footnotes":""},"categories":[36],"tags":[174],"class_list":["post-18428","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog","tag-dlfy"],"_links":{"self":[{"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/posts\/18428","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/comments?post=18428"}],"version-history":[{"count":0,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/posts\/18428\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/media\/3671"}],"wp:attachment":[{"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/media?parent=18428"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/categories?post=18428"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/tags?post=18428"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}