{"id":2083,"date":"2015-03-05T23:56:25","date_gmt":"2015-03-05T15:56:25","guid":{"rendered":"http:\/\/blog.qdac.cc\/?p=2083"},"modified":"2015-03-05T23:56:25","modified_gmt":"2015-03-05T15:56:25","slug":"%e3%80%90%e8%a2%abc%e6%8a%98%e8%85%be%e7%b3%bb%e5%88%97%e3%80%91%e7%94%a8c%e8%b0%83diocp%e7%bc%96%e7%a0%81%e5%ae%a2%e6%88%b7%e7%ab%af%e9%80%9a%e4%bf%a1","status":"publish","type":"post","link":"https:\/\/blog.qdac.cc\/?p=2083","title":{"rendered":"\u3010\u88abC\u6298\u817e\u7cfb\u5217\u3011\u7528C\u8c03DIOCP\u7f16\u7801\u5ba2\u6237\u7aef\u901a\u4fe1"},"content":{"rendered":"<p>\u524d\u51e0\u5929\u6709\u4e2a\u670b\u53cb\uff0c\u8bf4\u4ed6\u4eec\u516c\u53f8\u505a\u624b\u6e38\uff0c\u670d\u52a1\u7aef\u7528\u7684DIOCP3\u91cc\u9762\u505a\u6587\u4ef6\u670d\u52a1\u5668\uff0c\u5ba2\u6237\u7aef\u7528cocos-x\uff0c\u5728\u8c03\u8bd5\u4e0ediocp\u901a\u4fe1\u65f6\u8001\u662f\u5931\u8d25\uff01<\/p>\n<p>&nbsp;<\/p>\n<p>\u4e8e\u662f\uff0c\u6211\u4e0b\u8f7d\u4e86\u4e00\u4e2aCodeblocks\u7ecf\u8fc7\u51e0\u4e2a\u5c0f\u65f6\u7684\u6298\u817e\uff0c\u7ec8\u4e8e\u6298\u817e\u51fa\u6765\u4e86\uff0c\u628a\u5176\u4e2d\u7684\u4e00\u4e9b\u5fc3\u9178\u8bb0\u5f55\u4e0b\uff0c\u4ee5\u4fbf\u4ee5\u540e\u67e5\u9605\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>1.windows\u4e0b\u9762\u4f7f\u7528socket\u7684\u4e00\u4e9b\u51fd\u6570\u65f6\uff0c\u9700\u8981\u8bbe\u7f6e\u5de5\u7a0b\u7684\u9009\u9879\u6216\u8005\u5de5\u5177\u7684\u7f16\u8bd1\u9009\u9879<\/p>\n<p>[project \u2013&gt; build options]-&gt;[linker settings]\u6216\u8005[setting]-&gt;[complier]-&gt;Linker settings]\u4e2d\u6dfb\u52a0<\/p>\n<p>F:\\Tools\\C\\CodeBlocks\\MinGW\\lib\\*.a \u5230 [link libraries]\u4e2d<\/p>\n<p>\u8981\u4e0d\u7136\u4f1a\u51fa\u73b0\u7f16\u8bd1\u9519\u8bef<\/p>\n<p><font color=\"#ff0000\">undefined reference to <\/font><a href=\"mailto:`WSAStartup@8'\"><font color=\"#ff0000\">`WSAStartup@8&#8242;<\/font><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>2.\u5173\u4e8ec\u4e2d\u7684extern\u548cstatic<\/p>\n<p>&nbsp; \u767e\u5ea6\u4e0a\u9762\u6709\u6bd4\u8f83\u591a\u7684\u89e3\u91ca\uff0c<\/p>\n<p>&nbsp; extern \u8868\u793a\u4fee\u9970\u7684\u51fd\u6570\u6216\u8005\u53d8\u91cf\u662f\u4ece\u5176\u4ed6\u6587\u4ef6\u4e2d\u5f15\u7528\u3002(extern\u544a\u8bc9\u7f16\u8bd1\u5668\u8fd9\u4e2a\u53d8\u91cf\u6216\u8005\u51fd\u6570\u5728\u5176\u4ed6\u6587\u4ef6\u91cc\u5df2\u7ecf\u88ab\u5b9a\u4e49\u4e86)<\/p>\n<p>&nbsp; static \u8868\u793a\u4fee\u9970\u7684\u51fd\u6570\u6216\u8005\u53d8\u91cf\u53ea\u80fd\u5728\u672c\u6587\u4ef6\u4e2d\u4f7f\u7528\u3002static\u8fd8\u53ef\u4ee5\u4fee\u9970\u5c40\u90e8\u53d8\u91cf\uff0c\u8868\u793a\u5c40\u90e8\u53d8\u91cf\u5728\u9000\u51fa\u51fd\u6570\u540e\uff0c\u8be5\u53d8\u91cf\u4e0d\u53ef\u7528\uff0c\u4f46\u662f\u518d\u6b21\u8fdb\u5165\u5230\u51fd\u6570\u65f6\uff0c\u8be5\u53d8\u91cf\u4f1a\u4fdd\u5b58\u4e4b\u524d\u7684\u503c\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>\u4e0b\u9762\u4e3a\u8c03\u8bd5\u7684\u622a\u56fe(\u8be5\u4ee3\u7801\u653e\u5728\u76ee\u5f55diocp-v5\\samples\\StreamCoderDEMO\\c_codeblocks\u7f16\u5199)<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/images.cnitblog.com\/blog\/1998\/201503\/052348103052917.png\"><\/p>\n<p>\u4e0a\u9762\u622a\u56fe\u8bf4\u660e\u4e0e\u670d\u52a1\u5668\u8fdb\u884c\u4e86\u4e00\u6b21\u901a\u4fe1\uff0c\u670d\u52a1\u5668\u63a5\u6536\u7279\u5b9a\u7684\u7f16\u7801\u683c\u5f0f(Flag + CheckValue + datalen + data)<\/p>\n<p>\u53d1\u9001\u8fc7\u53bb\u540e\uff0c\u670d\u52a1\u7aef\u4f1a\u8fdb\u884c\u7f16\u7801\u539f\u6837\u8fd4\u56de\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>\u603b\u7ed3:<\/p>\n<p>&nbsp;&nbsp;&nbsp; \u63a5\u89e6\u4e00\u95e8\u5176\u4ed6\u8bed\u8a00\uff0c\u9700\u8981\u591a\u53bb\u5199\u4ee3\u7801\uff0c\u53ea\u6709\u5728\u5199\u7684\u8fc7\u7a0b\u5f53\u4e2d\u624d\u4f1a\u53bb\u78b0\u5230\u95ee\u9898\uff0c\u89e3\u51b3\u95ee\u9898\uff0c\u79ef\u7d2f\u88ab\u5751\u7684\u7ecf\u9a8c\u3002\u601d\u8def\u548c\u60f3\u6cd5\u6709\u4e86\uff0c\u5269\u4e0b\u7684\u5c31\u662f\u591a\u88ab\u5751\u70b9\u5c31\u597d\u4e86<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u51e0\u5929\u6709\u4e2a\u670b\u53cb\uff0c\u8bf4\u4ed6\u4eec\u516c\u53f8\u505a\u624b\u6e38\uff0c\u670d\u52a1\u7aef [&hellip;]<\/p>\n","protected":false},"author":6,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","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":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[43],"tags":[31,346,347],"class_list":["post-2083","post","type-post","status-publish","format-standard","hentry","category-diocp3","tag-c","tag-diocp","tag-socket"],"views":3684,"_links":{"self":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/2083","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2083"}],"version-history":[{"count":1,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/2083\/revisions"}],"predecessor-version":[{"id":2084,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/2083\/revisions\/2084"}],"wp:attachment":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2083"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2083"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2083"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}