linux\u7cfb\u7edf\u5927\u5c0f<\/strong>\uff0c\u8bfb\u53d6\u76ee\u5f55\u4e0b\u6587\u4ef6\u5217\u8868<\/p>\nclosedir\u5173\u6389\u76ee\u5f55\u5728\u8bfb\u53d6\u5b8c\u6210\u540e\uff0c\u8bb0\u5f97\u5173\u6389\u76ee\u5f55<\/p>\n
sync\u540c\u6b65\u6570\u636e\u5230c\u76d8\u8fd9\u4e2a\u51fd\u6570\u901a\u5e38\u5728\u66f4\u6539\u6587\u4ef6\uff0c\u5199\u5165\u6570\u636e\u540e\u8c03\u7528\uff0c\u8ba9\u7cfb\u7edf\u628a\u6570\u636e\u540c\u6b65\u5230c\u76d8<\/p>\n
\u6807\u51c6IO\u5e93<\/p>\n
\u6bd4\u8f83\u5e38\u7528<\/p>\n
\u6240\u8c13\u6807\u51c6IO\u5e93\uff0c\u5f53\u7136\u662fC\u8bed\u8a00\u91cc\u7684\u6587\u4ef6IO\uff0c\u53e6\u5916\u8fd9\u513f\u9762\u7684IO\u4e0e\u4e0a\u9762\u63d0\u53ca\u7684\u201c\u6587\u4ef6IO\u201d\u5728\u6587\u4ef6\u7684\u8bfb\u5199\u4e0a\u6709\u4e2a\u533a\u522b\uff0c\u6807\u51c6IO\u662f\u6709\u7f13\u5b58\u7684\uff0c\u800cLinux\u7cfb\u7edf\u7684\u6587\u4ef6IO\u51fd\u6570\u662f\u65e0\u7f13\u5b58\u7684\u3002<\/p>\n
\u4e3b\u8981\u662f\u6587\u4ef6\u64cd\u4f5c\u51fd\u6570\uff1a<\/p>\n
\u51fd\u6570\u540d\u7b80\u4ecb\u901a\u5e38\u5982\u4f55\u7528<\/p>\n
fopen\u6253\u5f00\u6587\u4ef6\u653e\u6587\u4ef6\u6587\u4ef6\u524d\u5148\u8c03\u7528fopen\u83b7\u53d6\u6587\u4ef6\u53e5\u67c4<\/p>\n
fclose\u5173\u6389\u6587\u4ef6\u6587\u4ef6\u8bbf\u95ee\u7ed3\u675f\u540e\uff0c\u8bb0\u5f97\u5173\u6389\u6587\u4ef6\uff0c\u5426\u5219\u81f4\u4f7f\u663e\u5b58\u6cc4\u6f0f<\/p>\n
fread\u8bfb\u53d6\u6587\u4ef6\u8bfb\u53d6\u6587\u4ef6\u6570\u636e<\/p>\n
fseek\u66f4\u6539\u6587\u4ef6\u8bfb\u5199\u4f4d\u7f6e\u7528\u4e8e\u66f4\u6539\u6587\u4ef6\u8bfb\u5199\u7684\u4f4d\u7f6e\u504f\u659c\u91cf<\/p>\n
\u8fdb\u7a0b\u63a7\u5236<\/p>\n
\u901a\u5e38<\/p>\n
\u5047\u5982\u4f60\u4e0d\u4f7f\u7528\u591a\u8fdb\u7a0b\u7f16\u7a0b\u7684\u8bdd\uff0c\u8fd9\u4e00\u9879\u53ef\u80fd\u5c31\u7528\u7684\u4e0d\u591a\uff0c\u6211\u7684\u4ee3\u7801\u91cc\u7528\u7684\u4e5f\u4e0d\u662f\u592a\u591a\u3002<\/p>\n
\u8fd9\u4e2a\u77e5\u8bc6\u70b9\u4e3b\u8981\u662f\u8fdb\u7a0b\u7684\u521b\u5efa\u3001\u5b50\u8fdb\u7a0b\u7ba1\u7406\u3001\u8fdb\u7a0b\u9000\u51fa\u8d44\u6e90\u91ca\u653e\u7b49\u7b49\u3002<\/p>\n
\u7ebf\u7a0b\u7f16\u7a0b<\/p>\n
\u6bd4\u8f83\u5e38\u7528<\/p>\n
\u4e0a\u4e86\u7cfb\u7edf\uff0c\u901a\u5e38\u8dd1\u7684\u4efb\u52a1\u90fd\u4f1a\u6bd4\u8f83\u591a\uff0c\u7ebf\u7a0b\u662f\u6bd4\u8f83\u5e38\u7528\u7684\uff0c\u901a\u5e38\u53ef\u4ee5\u5206\u4e3a\u4e24\u79cd\uff0c\u4e00\u79cd\u662f\u957f\u65f6\u95f4\u8fd0\u884c\u7684\u4efb\u52a1\uff0c\u4e00\u79cd\u662f\u6267\u884c\u5b8c\u4efb\u52a1\u81ea\u884c\u9000\u51fa\u3002\u73b0\u4ecaC++11\u65e9\u5df2\u652f\u6301\u4e86\u7ebf\u7a0b\uff0c\u4f7f\u7528\u4e0a\u53bb\u5341\u5206\u4fbf\u6377\u3002\u4e4b\u524d\u6ca1\u6709C++11\u65f6linux shell\uff0c\u4e3a\u4e86\u4fbf\u6377\u4f7f\u7528\uff0c\u90fd\u662f\u5bf9pthrea_\u7c07\u51fd\u6570\u8fdb\u884c\u4e86\u4e8c\u6b21\u5c01\u88c5\u3002<\/p>\n
\u4e2d\u7ea7IO<\/p>\n
\u5e38\u7528<\/p>\n
\u53ef\u80fd\u4f60\u4f1a\u6bd4\u8f83\u5947\u602a\uff0c\u4e3a\u4f55\u5982\u6b64\u591a\u201cIO\u201d\u76f8\u5173\u7684\u4e1c\u897f\uff1a\u6587\u4ef6IO\u3001\u6807\u51c6\u6587\u4ef6IO\u3001\u9ad8\u7ea7IO\uff01<\/p>\n
\u662f\u7684\uff0c\u8fd9\u513f\u7684IO\u6bd4\u8f83\u591a\uff0c\u524d\u4e24\u4e2a\u201cIO\u201d\u8fd8\u6709\u70b9\u76f8\u50cf\uff0c\u8fd9\u4e2a\u4e2d\u7ea7IO\u548c\u4e0a\u9762\u4e24\u4e2a\u6709\u70b9\u4e0d\u592a\u4e00\u6837\u3002<\/p>\n
\u4e2d\u7ea7IO\u91cc\u4e3b\u8981\u662f\u8bb2\u7684IO\u64cd\u4f5c\u7684\u65b9\u6cd5\uff1a\u963b\u585e\u3001\u975e\u963b\u585e\u63a7\u5236\uff0c\u6700\u4e3b\u8981\u7684\u662f\u901a\u8fc7select\u548cpoll\u5b9e\u73b0IO\u591a\u8def\u590d\u7528\uff0c\u8fd9\u6837\u53ef\u4ee5\u5b9e\u73b0\u7a0b\u5e8f\u7684\u5f02\u6b65\u6267\u884c\u3002\u73b0\u4eca\u7528\u7684\u6bd4\u8f83\u591a\u7684Nginx\uff0c\u5c31\u662f\u4f7f\u7528\u7684epoll\u6a21\u578b\uff0c\u5b9e\u73b0\u7684\u9ad8\u5e76\u53d1\u3002<\/p>\n
\u8fdb\u7a0b\u95f4\u901a\u8baf<\/p>\n
\u5341\u5206\u5e38\u7528<\/p>\n
\u901a\u5e38\u5728linux\u7cfb\u7edf\u4e0b\u8fb9\uff0c\u65e2\u7136\u662f\u7cfb\u7edf\uff0c\u5c31\u4e0d\u6b62\u4e00\u4e2a\u5e94\u7528\u7a0b\u5e8f\u5728\u8fd0\u884c\uff0c\u90a3\u591a\u4e2a\u5e94\u7528\u7a0b\u5e8f\uff0c\u90fd\u4f1a\u987b\u8981\u6570\u636e\u4ea4\u4e92\uff0c\u8fd9\u4e48\uff0c\u5c31\u7528\u5230\u4e86\u8fdb\u7a0b\u95f4\u901a\u8baf\uff0c\u8fdb\u7a0b\u95f4\u901a\u8baf\u6709\u8bb8\u591a\u5f00\u6e90\u7684\u5de5\u5177\uff08\u4f8b\u5982DBUS\uff09\uff0c\u8fd9\u513f\u7b80\u5355\u4ecb\u7ecd\u4e00\u4e0b\u7cfb\u7edf\u91cc\u63d0\u4f9b\u7684\u901a\u8baf\u65b9\u6cd5\uff1a<\/p>\n
\u540d\u79f0\u7b80\u4ecb<\/p>\n
\u7ba1\u7ebf\u901a\u5e38\u7528\u4e8e\u6bcd\u5b50\u8fdb\u7a0b\u95f4\u901a\u8baf\uff0c\u6709\u540d\u7ba1\u7ebf\u53ef\u4ee5\u8de8\u7a0b\u5e8f<\/p>\n
\u6d88\u606f\u961f\u5217\u6d88\u606f\u961f\u5217\u53ef\u4ee5\u5206\u7c7b\u578b\uff0c\u9002\u7528\u4e8e\u6570\u636e\u91cf\u5c0f\u7684\uff0c\u7b80\u5355\u901a\u8baf<\/p>\n
\u8baf\u53f7\u91cfPV\u64cd\u4f5c\uff0c\u7528\u4e8e\u540c\u6b65\uff0c\u53ef\u4ee5\u4e0e\u5171\u4eab\u663e\u5b58\u642d\u914d\u7528\uff0c\u5199\u5b8c\u6570\u636e\uff0c\u544a\u8bc9\u53e6\u4e00\u4e2a\u7ebf\u7a0b\u53ef\u4ee5\u8bfb\u53d6\u4e86<\/p>\n
\u5171\u4eab\u663e\u5b58\u9002\u7528\u4e8e\u5927\u6570\u636e\u91cf\u7684\u4f20\u8f93<\/p>\n
socketsocke\u9664\u4e86\u662f\u7f51\u8def\u901a\u8baf\u7684\u63d2\u53e3\uff0c\u4e5f\u53ef\u4ee5\u662f\u672c\u5730\u8fdb\u7a0b\u95f4\u901a\u8baf\uff08UNIXsocke\uff09\uff0c\u8fd9\u4e9b\u65b9\u6cd5\u5f88\u5e38\u7528<\/p>\n
\u6570\u636e\u5e93<\/p>\n
\u5e38\u7528<\/p>\n
\u5047\u5982\u662f\u50a8\u5b58\u914d\u7f6e\u53c2\u6570\uff0c\u6211\u4e0d\u592a\u63a8\u8350\u7528\u6570\u636e\u5e93\uff0c\u7528json\u5c31\u5f88\u597d\u3002\u6570\u636e\u901a\u5e38\u7528\u4e8e\u50a8\u5b58\u6bd4\u8f83\u89c4\u5219\u7684\u6570\u636e\uff0c\u8fd9\u6837\u4fbf\u6377\u6570\u636e\u7684\u7ba1\u7406\u3002\u5728\u5d4c\u5165\u5f0f\u7cfb\u7edf\uff0c\u7528\u7684\u6bd4\u8f83\u591a\u7684\u662fsqlite\u6570\u636e\u5e93\u3002<\/p>\n
\u5e76\u53e3\u7f16\u7a0b<\/p>\n
\u6bd4\u8f83\u5e38\u7528<\/p>\n
\u5728Linux\u4e0b\uff0c\u975e\u5e38\u662f\u505a\u5d4c\u5165\u5f0f\u7cfb\u7edf\uff0c\u8fd9\u4e2a\u53ef\u80fd\u662f\u5c11\u4e0d\u4e86\u7684\uff0c\u6bd4\u8f83\u5e38\u7528\u3002\u867d\u7136\u5e76\u53e3\u7f16\u7a0b\u4e5f\u5f88\u7b80\u5355\uff0c\u53ef\u80fd200\u884c\u4ee3\u7801\u5c31\u53ef\u4ee5\u628a\u5e76\u53e3\u901a\u8baf\u6784\u5efa\u4e0a\u53bb\u4e86\u3002\u5e94\u7528\u5c42\u7684\u6570\u636e\u901a\u8baf\uff0c\u5c31\u662f\u4f7f\u7528write\u3001\u548cread\u51fd\u6570\u64cd\u4f5c\uff0c\u800c\u4e14\u5047\u5982\u60f3\u505a\u7684\u6bd4\u8f83\u597d\u4e00\u4e9b\uff0c\u5c31\u987b\u8981\u82b1\u70b9\u65f6\u95f4\u53bb\u505a\u4e2a\u8f6f\u4ef6\u6846\u67b6\uff0c\u4f8b\u5982\u501f\u52a9\u4e0a\u9762\u63d0\u53ca\u7684select\u5b9e\u73b0\u5f02\u6b65\u64cd\u4f5c\uff08\u524d\u9762\u6587\u7ae0\u4f1a\u4ecb\u7ecd\u5b9e\u73b0\u65b9\u6cd5\u4ee5\u53ca\u5e76\u53e3\u7684\u5c01\u88c5\uff09\u3002<\/p>\n
\u7f51\u8def\u7f16\u7a0b<\/p>\n
\u8d85\u7ea7\u5e38\u7528<\/p>\n
\u76f8\u4fe1\u73b0\u4eca\u7684\u5d4c\u5165\u5f0f\u8bbe\u5907\u57fa\u672c\u4e0a\u90fd\u987b\u8981\u7f51\u8def\u901a\u8baf\u529f\u80fd\uff0c\u6240\u4ee5\uff0c\u7f51\u8def\u7f16\u7a0b\u81ea\u7136\u662f\u5341\u5206\u5e38\u7528\u7684\u3002\u7279\u5907\u662f\u73b0\u4eca\u7269\u8054\u7f51\u7684\u53d1\u5c55\uff0c\u4e07\u7269\u4e92\u8054\u3002Linux\u4e0b\u7684\u7f51\u8def\u7f16\u7a0b\uff0c\u6709\u4e00\u7cfb\u5217\u7684API\u51fd\u6570\uff0c\u633a\u591a\u7684\uff0c\u53c2\u6570\u914d\u7f6e\u4e5f\u6bd4\u8f83\u591a\uff0c\u521a\u5f00\u59cb\u4f1a\u8ba9\u4eba\u5f88\u96be\u53d7\uff0c\u4e0d\u6653\u5f97\u90a3\u4e2a\u53c2\u6570\u8bbe\u7f6e\u4e2a\u54ea\u4e9b\u503c\u5408\u9002\uff08\u6211\u4eec\u90fd\u662f\u6e10\u6e10\u8bd5\u9519\u8bd5\u4e0b\u6765\u7684\uff09\u3002\u8fd9\u4e2a\u4e5f\u4e0d\u7528\u62c5\u5fe7\uff0c\u6211\u65c1\u8fb9\u4f1a\u7ed9\u4f60\u4eec\u5206\u4eab\u4e0b\u6765\u6211\u7528C++\u5c01\u88c5\u597d\u7684\u7f51\u8def\u901a\u8baf\u5e93\uff0c\u5305\u62ecTCP\u3001UPD\u3001UDP\u7ec4\u64ad\u3001\u57df\u5957\u63a5\u5b57\uff08\u672c\u5730\uff09\u7b49\u7684\u5c01\u88c5\u3002<\/p>\n
\u7ed3\u675f\u8bed<\/p>\n
\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014<\/p>\n
\u7248\u6743\u7533\u660e\uff1a\u672c\u6587\u4e3aCSDN\u535a\u4e3b\u300cfensnote\u300d\u7684\u539f\u521b\u6587\u7ae0\uff0c\u9075\u5b88CC4.0BY-SA\u7248\u6743\u5408\u540c\uff0c\u8f6c\u8f7d\u8bf7\u9644\u4e0a\u539f\u6587\u51fa\u5904\u94fe\u63a5\u53ca\u672c\u7533\u660e\u3002<\/p>\n
\u539f\u6587\u94fe\u63a5\uff1a<\/p>\n","protected":false},"excerpt":{"rendered":"
Linux\u7cfb\u7edf\u5185\u6838\u662fC\u8bed\u8a00\u7f16\u5199\u7684\uff0c\u6240\u4ee5\uff0cLinux\u7cfb\u7edf\u5f00\u53d1\u53ef\u80fd\u4f1a\u548c\u5f88\u591a\u7cfb\u7edfAPI\u6253\u4ea4\u9053\uff0c\u9700\u8981\u638c\u63e1C\u8bed\u8a00\u57fa\u7840\uff0cC\u8bed\u8a00\u662fLinux\u6700\u57fa\u7840\u7684\u5f00\u53d1\u8bed\u8a00\uff0c\u5f53\u7136\u4e5f\u53ef\u4ee5\u7528C++\u3002<\/p>\n","protected":false},"author":1,"featured_media":279899,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[988],"tags":[999],"class_list":["post-279898","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tougao","tag-999"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/279898","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=279898"}],"version-history":[{"count":0,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/279898\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/279899"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=279898"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=279898"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=279898"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}