{"id":729,"date":"2022-05-22T10:19:12","date_gmt":"2022-05-22T02:19:12","guid":{"rendered":"https:\/\/www.fanyamin.com\/wordpress\/?p=729"},"modified":"2022-05-22T11:16:35","modified_gmt":"2022-05-22T03:16:35","slug":"%e5%bc%82%e6%ad%a5%e7%bc%96%e7%a8%8b%e6%a8%a1%e5%bc%8f","status":"publish","type":"post","link":"https:\/\/www.fanyamin.com\/wordpress\/?p=729","title":{"rendered":"\u5f02\u6b65\u7f16\u7a0b\u6a21\u5f0f"},"content":{"rendered":"<p>\u5927\u7ea6\u6709\u4e24\u79cd\u57fa\u672c\u7684\u5f02\u6b65\u7f16\u7a0b\u6a21\u5f0f<\/p>\n<ol>\n<li>Task-Based Asynchronous Pattern \u57fa\u4e8e\u4efb\u52a1\u7684\u5f02\u6b65\u6a21\u5f0f<\/li>\n<\/ol>\n<p>\u4ee5\u4e00\u4e2a\u5355\u4e2a\u7684\u65b9\u6cd5\uff08Task\uff09\u6765\u8868\u793a\u5f02\u6b65\u64cd\u4f5c\u7684\u53d1\u8d77\u548c\u5b8c\u6210\uff0c \u5b83\u5f15\u5165\u4e86 Async, Await \u8fd9\u6837\u7684\u5173\u952e\u5b57<br \/>\n\u4efb\u52a1\u6267\u884c\u4f1a\u8fd4\u56de\u4e00\u4e2a Promise \u6216 Future, \u4ee3\u8868\u672a\u6765\u6267\u884c\u7684\u7ed3\u679c<\/p>\n<ol start=\"2\">\n<li>Event-Based Asynchronous Pattern \u57fa\u4e8e\u4e8b\u4ef6\u7684\u5f02\u6b65\u6a21\u5f0f<\/li>\n<\/ol>\n<p>\u4ee5\u4e8b\u4ef6\u9a71\u52a8\u7684\u6a21\u5f0f\u6765\u63d0\u4f9b\u5f02\u6b65\u7684\u884c\u4e3a\uff0c\u4e3b\u8981\u4f7f\u7528\u4e86\u4e8b\u4ef6\u56de\u8c03\u548c\u4e8b\u4ef6\u5904\u7406\u5668\u7684\u65b9\u5f0f\uff0c\u7c7b\u4f3c\u4e8e\u89c2\u5bdf\u8005\u6a21\u5f0f\u7684\u7ed3\u6784<\/p>\n<p>\u5b83\u9075\u5faa\u4e86\u8457\u540d\u7684\u597d\u83b1\u575e\u539f\u5219 \u201cDon't call us, we'll call you\u201d - \u201c\u522b\u6253\u7535\u8bdd\u7ed9\u6211\u4eec\uff0c\u6211\u4eec\u4f1a\u6253\u7ed9\u4f60\u7684\u201d<\/p>\n<p>\u5728\u5177\u4f53\u5b9e\u73b0\u4e0a\uff0c\u6709\u4e09\u79cd\u6a21\u578b<\/p>\n<ol>\n<li>\u591a\u8fdb\u7a0b<\/li>\n<\/ol>\n<p>RPC \u8fdc\u7a0b\u8fc7\u7a0b\u8c03\u7528\u5c31\u662f\u5178\u578b\u7684\u7528\u4f8b\uff0c\u5728\u591a\u4e2a\u8fdb\u7a0b\u95f4\u901a\u8fc7\u7f51\u7edc\u6d88\u606f\u4f20\u8f93\u6765\u8fdb\u884c\u5f02\u6b65\u8c03\u7528\uff0c\u4f8b\u5982 Ajax\u3002<br \/>\n\u5728\u4e00\u53f0\u4e3b\u673a\u7684\u591a\u8fdb\u7a0b\u8fd8\u53ef\u4ee5\u4f7f\u7528\u4f17\u591a\u7684 IPC \u65b9\u6cd5\uff0c\u6211\u89c9\u5f97\u6700\u597d\u7528\u7684\u8fd8\u662f UDS (Unix Domain Socket) \u5176\u5730\u5740\u65cf\u4e3a AF_UNIX\uff0cSocket type \u53ef\u4ee5\u662f SOCK_STREAM(\u7c7b\u6bd4 TCP) \u548c SOCK_DGRAM(\u7c7b\u6bd4 UDP), SCOK_SEQPACKET(\u7c7b\u6bd4 SCTP)<\/p>\n<pre><code>nc -U \/tmp\/test.sock -u -l\nlsof \/tmp\/test.sock\nnc \/tmp\/test.sock -u<\/code><\/pre>\n<ul>\n<li>-U \u53c2\u6570\u8868\u793a Unix Socket file<\/li>\n<li>-l \u53c2\u6570\u8868\u793a Listen \u4fa6\u542c\u63a5\u5165\u7684\u8fde\u63a5<\/li>\n<li>-u \u53c2\u6570\u8868\u793a SOCK_DGRAM<\/li>\n<\/ul>\n<p>\u4ee3\u7801\u793a\u4f8b<\/p>\n<pre><code><\/code><\/pre>\n<ol start=\"2\">\n<li>\u591a\u7ebf\u7a0b<\/li>\n<\/ol>\n<p>\u4e3a\u6253\u7834\u987a\u5e8f\u6267\u884c\u548c\u963b\u585e\u7b49\u5f85\u7684\u9650\u5236\uff0c\u5f15\u5165\u591a\u4e2a\u7ebf\u7a0b\uff0c\u5728\u4e0d\u540c\u7684\u7ebf\u7a0b\u4e2d\u6267\u884c\u4efb\u52a1\uff0c\u81ea\u7136\u80fd\u505a\u5230\u5f02\u6b65\uff0c\u4e0d\u8fc7\u8981\u8003\u8651\u5230\u7ebf\u7a0b\u5b89\u5168\u548c\u7ebf\u7a0b\u95f4\u7684\u901a\u8baf\uff0c\u6700\u5e38\u7528\u7684\u5c31\u662f\u7ebf\u7a0b\u6c60\uff0c\u7ebf\u7a0b\u961f\u5217\u548c\u7ebf\u7a0b\u4e4b\u95f4\u7684\u9501\u7684\u4f7f\u7528<\/p>\n<ol start=\"3\">\n<li>\u534f\u7a0b<br \/>\n\u534f\u7a0b\u662f\u6307\u5728\u5355\u4e2a\u7ebf\u7a0b\u4e0a\u8fd0\u884c\u7684\u8fc7\u7a0b\uff0c\u5b83\u4eec\u53ef\u4ee5\u6682\u505c\u548c\u91cd\u542f\uff0c<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>\u5927\u7ea6\u6709\u4e24\u79cd\u57fa\u672c\u7684\u5f02\u6b65\u7f16\u7a0b\u6a21\u5f0f Task-Based Asynchronous Pattern \u57fa\u4e8e\u4efb\u52a1\u7684\u5f02\u6b65\u6a21\u5f0f \u4ee5\u4e00\u4e2a\u5355\u4e2a\u7684\u65b9\u6cd5\uff08Task\uff09\u6765\u8868\u793a\u5f02\u6b65\u64cd\u4f5c\u7684\u53d1\u8d77\u548c\u5b8c\u6210\uff0c \u5b83\u5f15\u5165\u4e86 Async, Await \u8fd9\u6837\u7684\u5173\u952e\u5b57 \u4efb\u52a1\u6267\u884c\u4f1a\u8fd4\u56de\u4e00\u4e2a Promise \u6216 Future, \u4ee3\u8868\u672a\u6765\u6267\u884c\u7684\u7ed3\u679c Event-Based Asynchronous Pattern \u57fa\u4e8e\u4e8b\u4ef6\u7684\u5f02\u6b65\u6a21\u5f0f \u4ee5\u4e8b\u4ef6\u9a71\u52a8\u7684\u6a21\u5f0f\u6765\u63d0\u4f9b\u5f02\u6b65\u7684\u884c\u4e3a\uff0c\u4e3b\u8981\u4f7f\u7528\u4e86\u4e8b\u4ef6\u56de\u8c03\u548c\u4e8b\u4ef6\u5904\u7406\u5668\u7684\u65b9\u5f0f\uff0c\u7c7b\u4f3c\u4e8e\u89c2\u5bdf\u8005\u6a21\u5f0f\u7684\u7ed3\u6784 \u5b83\u9075\u5faa\u4e86\u8457\u540d\u7684\u597d\u83b1\u575e\u539f\u5219 \u201cDon&#8217;t call us, we&#8217;ll call you\u201d &#8211; \u201c\u522b\u6253\u7535\u8bdd\u7ed9\u6211\u4eec\uff0c\u6211\u4eec\u4f1a\u6253\u7ed9\u4f60\u7684\u201d \u5728\u5177\u4f53\u5b9e\u73b0\u4e0a\uff0c\u6709\u4e09\u79cd\u6a21\u578b \u591a\u8fdb\u7a0b RPC \u8fdc\u7a0b\u8fc7\u7a0b\u8c03\u7528\u5c31\u662f\u5178\u578b\u7684\u7528\u4f8b\uff0c\u5728\u591a\u4e2a\u8fdb\u7a0b\u95f4\u901a\u8fc7\u7f51\u7edc\u6d88\u606f\u4f20\u8f93\u6765\u8fdb\u884c\u5f02\u6b65\u8c03\u7528\uff0c\u4f8b\u5982 Ajax\u3002 \u5728\u4e00\u53f0\u4e3b\u673a\u7684\u591a\u8fdb\u7a0b\u8fd8\u53ef\u4ee5\u4f7f\u7528\u4f17\u591a\u7684 IPC \u65b9\u6cd5\uff0c\u6211\u89c9\u5f97\u6700\u597d\u7528\u7684\u8fd8\u662f UDS (Unix Domain Socket) \u5176\u5730\u5740\u65cf\u4e3a AF_UNIX\uff0cSocket type \u53ef\u4ee5\u662f SOCK_STREAM(\u7c7b\u6bd4 TCP) \u548c SOCK_DGRAM(\u7c7b\u6bd4 UDP), SCOK_SEQPACKET(\u7c7b\u6bd4 SCTP) nc -U \/tmp\/test.sock [&hellip;] <a class=\"read-more\" href=\"https:\/\/www.fanyamin.com\/wordpress\/?p=729\" title=\"Permanent Link to: \u5f02\u6b65\u7f16\u7a0b\u6a21\u5f0f\">&rarr;Read&nbsp;more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-729","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/729"}],"collection":[{"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=729"}],"version-history":[{"count":3,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/729\/revisions"}],"predecessor-version":[{"id":732,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/729\/revisions\/732"}],"wp:attachment":[{"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=729"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=729"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=729"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}