{"id":170827,"date":"2020-01-27T09:08:39","date_gmt":"2020-01-27T01:08:39","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=170827"},"modified":"2020-01-19T11:09:02","modified_gmt":"2020-01-19T03:09:02","slug":"tcp-long-short","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/tcp-long-short.html","title":{"rendered":"python\u57fa\u7840\u5b66\u4e60-tcp\u957f\u8fde\u63a5\u548c\u77ed\u8fde\u63a5\u4ecb\u7ecd"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\ntcp\u957f\u8fde\u63a5\u548c\u77ed\u8fde\u63a5
\nTCP\u5728\u771f\u6b63\u7684\u8bfb\u5199\u64cd\u4f5c\u4e4b\u524d\uff0cserver\u4e0eclient\u4e4b\u95f4\u5fc5\u987b\u5efa\u7acb\u4e00\u4e2a\u8fde\u63a5\uff0c\u5f53\u8bfb\u5199\u64cd\u4f5c\u5b8c\u6210\u540e\uff0c\u53cc\u65b9\u4e0d\u518d\u9700\u8981\u8fd9\u4e2a\u8fde\u63a5\u65f6\u5b83\u4eec\u53ef\u4ee5\u91ca\u653e\u8fd9\u4e2a\u8fde\u63a5\uff0c\u8fde\u63a5\u7684\u5efa\u7acb\u901a\u8fc7\u4e09\u6b21\u63e1\u624b\uff0c\u91ca\u653e\u5219\u9700\u8981\u56db\u6b21\u63e1\u624b\uff0c\u6240\u4ee5\u8bf4\u6bcf\u4e2a\u8fde\u63a5\u7684\u5efa\u7acb\u90fd\u662f\u9700\u8981\u8d44\u6e90\u6d88\u8017\u548c\u65f6\u95f4\u6d88\u8017\u7684\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

TCP\u901a\u4fe1\u7684\u6574\u4e2a\u8fc7\u7a0b\uff0c\u5982\u4e0b\u56fe:
\n\"\"<\/a><\/p>\n

1. TCP\u77ed\u8fde\u63a5 <\/strong><\/div>\n

\u6a21\u62df\u4e00\u79cdTCP\u77ed\u8fde\u63a5\u7684\u60c5\u51b5:<\/p>\n

    \n
  1. \n
      \n
    1. client \u5411 server \u53d1\u8d77\u8fde\u63a5\u8bf7\u6c42<\/li>\n
    2. server \u63a5\u5230\u8bf7\u6c42\uff0c\u53cc\u65b9\u5efa\u7acb\u8fde\u63a5<\/li>\n
    3. client \u5411 server \u53d1\u9001\u6d88\u606f<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n
        \n
      1. server \u56de\u5e94 client<\/li>\n
      2. \u4e00\u6b21\u8bfb\u5199\u5b8c\u6210\uff0c\u6b64\u65f6\u53cc\u65b9\u4efb\u4f55\u4e00\u4e2a\u90fd\u53ef\u4ee5\u53d1\u8d77 close \u64cd\u4f5c<\/li>\n<\/ol>\n

        \u5728\u6b65\u9aa45\u4e2d\uff0c\u4e00\u822c\u90fd\u662f client \u5148\u53d1\u8d77 close \u64cd\u4f5c\u3002\u5f53\u7136\u4e5f\u4e0d\u6392\u9664\u6709\u7279\u6b8a\u7684\u60c5\u51b5\u3002<\/p>\n

        \u4ece\u4e0a\u9762\u7684\u63cf\u8ff0\u770b\uff0c\u77ed\u8fde\u63a5\u4e00\u822c\u53ea\u4f1a\u5728 client\/server \u95f4\u4f20\u9012\u4e00\u6b21\u8bfb\u5199\u64cd\u4f5c\uff01<\/p>\n

        2. TCP\u957f\u8fde\u63a5 <\/strong><\/div>\n

        \u518d\u6a21\u62df\u4e00\u79cd\u957f\u8fde\u63a5\u7684\u60c5\u51b5:<\/p>\n

          \n
        1. client \u5411 server \u53d1\u8d77\u8fde\u63a5<\/li>\n
        2. server \u63a5\u5230\u8bf7\u6c42\uff0c\u53cc\u65b9\u5efa\u7acb\u8fde\u63a5<\/li>\n
        3. client \u5411 server \u53d1\u9001\u6d88\u606f<\/li>\n
        4. server \u56de\u5e94 client<\/li>\n
        5. \u4e00\u6b21\u8bfb\u5199\u5b8c\u6210\uff0c\u8fde\u63a5\u4e0d\u5173\u95ed<\/li>\n
        6. \u540e\u7eed\u8bfb\u5199\u64cd\u4f5c...<\/li>\n
        7. \u957f\u65f6\u95f4\u64cd\u4f5c\u4e4b\u540eclient\u53d1\u8d77\u5173\u95ed\u8bf7\u6c42<\/li>\n<\/ol>\n
          3. TCP\u957f\/\u77ed\u8fde\u63a5\u64cd\u4f5c\u8fc7\u7a0b <\/strong><\/div>\n
          1 \u77ed\u8fde\u63a5\u7684\u64cd\u4f5c\u6b65\u9aa4\u662f\uff1a <\/strong><\/span><\/div>\n

          \u5efa\u7acb\u8fde\u63a5\u2014\u2014\u6570\u636e\u4f20\u8f93\u2014\u2014\u5173\u95ed\u8fde\u63a5...\u5efa\u7acb\u8fde\u63a5\u2014\u2014\u6570\u636e\u4f20\u8f93\u2014\u2014\u5173\u95ed\u8fde\u63a5<\/p>\n

          \"\"<\/a><\/p>\n

          3.2 \u957f\u8fde\u63a5\u7684\u64cd\u4f5c\u6b65\u9aa4\u662f\uff1a<\/strong><\/span><\/div>\n

          \u5efa\u7acb\u8fde\u63a5\u2014\u2014\u6570\u636e\u4f20\u8f93...\uff08\u4fdd\u6301\u8fde\u63a5\uff09...\u6570\u636e\u4f20\u8f93\u2014\u2014\u5173\u95ed\u8fde\u63a5<\/p>\n

          \"\"<\/a><\/p>\n

          4. TCP\u957f\/\u77ed\u8fde\u63a5\u7684\u4f18\u70b9\u548c\u7f3a\u70b9 <\/strong><\/div>\n
            \n
          • \u957f\u8fde\u63a5\u53ef\u4ee5\u7701\u53bb\u8f83\u591a\u7684TCP\u5efa\u7acb\u548c\u5173\u95ed\u7684\u64cd\u4f5c\uff0c\u51cf\u5c11\u6d6a\u8d39\uff0c\u8282\u7ea6\u65f6\u95f4\u3002\u5bf9\u4e8e\u9891\u7e41\u8bf7\u6c42\u8d44\u6e90\u7684\u5ba2\u6237\u6765\u8bf4\uff0c\u8f83\u9002\u7528\u957f\u8fde\u63a5\u3002<\/li>\n<\/ul>\n
              \n
            • client\u4e0eserver\u4e4b\u95f4\u7684\u8fde\u63a5\u5982\u679c\u4e00\u76f4\u4e0d\u5173\u95ed\u7684\u8bdd\uff0c\u4f1a\u5b58\u5728\u4e00\u4e2a\u95ee\u9898\uff0c\u968f\u7740\u5ba2\u6237\u7aef\u8fde\u63a5\u8d8a\u6765\u8d8a\u591a\uff0cserver\u65e9\u665a\u6709\u625b\u4e0d\u4f4f\u7684\u65f6\u5019\uff0c\u8fd9\u65f6\u5019server\u7aef\u9700\u8981\u91c7\u53d6\u4e00\u4e9b\u7b56\u7565\uff0c\u5982\u5173\u95ed\u4e00\u4e9b\u957f\u65f6\u95f4\u6ca1\u6709\u8bfb\u5199\u4e8b\u4ef6\u53d1\u751f\u7684\u8fde\u63a5\uff0c\u8fd9\u6837\u53ef\u4ee5\u907f\u514d\u4e00\u4e9b\u6076\u610f\u8fde\u63a5\u5bfc\u81f4server\u7aef\u670d\u52a1\u53d7\u635f\uff1b\u5982\u679c\u6761\u4ef6\u518d\u5141\u8bb8\u5c31\u53ef\u4ee5\u4ee5\u5ba2\u6237\u7aef\u673a\u5668\u4e3a\u9897\u7c92\u5ea6\uff0c\u9650\u5236\u6bcf\u4e2a\u5ba2\u6237\u7aef\u7684\u6700\u5927\u957f\u8fde\u63a5\u6570\uff0c\u8fd9\u6837\u53ef\u4ee5\u5b8c\u5168\u907f\u514d\u67d0\u4e2a\u86cb\u75bc\u7684\u5ba2\u6237\u7aef\u8fde\u7d2f\u540e\u7aef\u670d\u52a1\u3002<\/li>\n<\/ul>\n
                \n
              • \u77ed\u8fde\u63a5\u5bf9\u4e8e\u670d\u52a1\u5668\u6765\u8bf4\u7ba1\u7406\u8f83\u4e3a\u7b80\u5355\uff0c\u5b58\u5728\u7684\u8fde\u63a5\u90fd\u662f\u6709\u7528\u7684\u8fde\u63a5\uff0c\u4e0d\u9700\u8981\u989d\u5916\u7684\u63a7\u5236\u624b\u6bb5\u3002<\/li>\n<\/ul>\n
                  \n
                • \u4f46\u5982\u679c\u5ba2\u6237\u8bf7\u6c42\u9891\u7e41\uff0c\u5c06\u5728TCP\u7684\u5efa\u7acb\u548c\u5173\u95ed\u64cd\u4f5c\u4e0a\u6d6a\u8d39\u65f6\u95f4\u548c\u5e26\u5bbd\u3002<\/li>\n<\/ul>\n
                  5. TCP\u957f\/\u77ed\u8fde\u63a5\u7684\u5e94\u7528\u573a\u666f <\/strong><\/div>\n
                    \n
                  • \u957f\u8fde\u63a5\u591a\u7528\u4e8e\u64cd\u4f5c\u9891\u7e41\uff0c\u70b9\u5bf9\u70b9\u7684\u901a\u8baf\uff0c\u800c\u4e14\u8fde\u63a5\u6570\u4e0d\u80fd\u592a\u591a\u60c5\u51b5\u3002\u6bcf\u4e2aTCP\u8fde\u63a5\u90fd\u9700\u8981\u4e09\u6b21\u63e1\u624b\uff0c\u8fd9\u9700\u8981\u65f6\u95f4\uff0c\u5982\u679c\u6bcf\u4e2a\u64cd\u4f5c\u90fd\u662f\u5148\u8fde\u63a5\uff0c\u518d\u64cd\u4f5c\u7684\u8bdd\u90a3\u4e48\u5904\u7406\u901f\u5ea6\u4f1a\u964d\u4f4e\u5f88\u591a\uff0c\u6240\u4ee5\u6bcf\u4e2a\u64cd\u4f5c\u5b8c\u540e\u90fd\u4e0d\u65ad\u5f00\uff0c\u518d\u6b21\u5904\u7406\u65f6\u76f4\u63a5\u53d1\u9001\u6570\u636e\u5305\u5c31OK\u4e86\uff0c\u4e0d\u7528\u5efa\u7acbTCP\u8fde\u63a5\u3002\u4f8b\u5982\uff1a\u6570\u636e\u5e93\u7684\u8fde\u63a5\u7528\u957f\u8fde\u63a5\uff0c\u5982\u679c\u7528\u77ed\u8fde\u63a5\u9891\u7e41\u7684\u901a\u4fe1\u4f1a\u9020\u6210socket\u9519\u8bef\uff0c\u800c\u4e14\u9891\u7e41\u7684socket \u521b\u5efa\u4e5f\u662f\u5bf9\u8d44\u6e90\u7684\u6d6a\u8d39\u3002<\/li>\n
                  • \u800c\u50cfWEB\u7f51\u7ad9\u7684http\u670d\u52a1\u4e00\u822c\u90fd\u7528\u77ed\u94fe\u63a5\uff0c\u56e0\u4e3a\u957f\u8fde\u63a5\u5bf9\u4e8e\u670d\u52a1\u7aef\u6765\u8bf4\u4f1a\u8017\u8d39\u4e00\u5b9a\u7684\u8d44\u6e90\uff0c\u800c\u50cfWEB\u7f51\u7ad9\u8fd9\u4e48\u9891\u7e41\u7684\u6210\u5343\u4e0a\u4e07\u751a\u81f3\u4e0a\u4ebf\u5ba2\u6237\u7aef\u7684\u8fde\u63a5\u7528\u77ed\u8fde\u63a5\u4f1a\u66f4\u7701\u4e00\u4e9b\u8d44\u6e90\uff0c\u5982\u679c\u7528\u957f\u8fde\u63a5\uff0c\u800c\u4e14\u540c\u65f6\u6709\u6210\u5343\u4e0a\u4e07\u7684\u7528\u6237\uff0c\u5982\u679c\u6bcf\u4e2a\u7528\u6237\u90fd\u5360\u7528\u4e00\u4e2a\u8fde\u63a5\u7684\u8bdd\uff0c\u90a3\u53ef\u60f3\u800c\u77e5\u5427\u3002\u6240\u4ee5\u5e76\u53d1\u91cf\u5927\uff0c\u4f46\u6bcf\u4e2a\u7528\u6237\u65e0\u9700\u9891\u7e41\u64cd\u4f5c\u60c5\u51b5\u4e0b\u9700\u7528\u77ed\u8fde\u597d\u3002<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"

                    TCP\u901a\u4fe1\u7684\u6574\u4e2a\u8fc7\u7a0b\uff0c\u5982\u4e0b\u56fe: \u6a21\u62df\u4e00\u79cdTCP\u77ed\u8fde\u63a5\u7684\u60c5\u51b5: client \u5411 server \u53d1\u8d77\u8fde\u63a5\u8bf7\u6c42 s […]<\/p>\n","protected":false},"author":643,"featured_media":170835,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-170827","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/170827","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\/643"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=170827"}],"version-history":[{"count":7,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/170827\/revisions"}],"predecessor-version":[{"id":171013,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/170827\/revisions\/171013"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/170835"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=170827"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=170827"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=170827"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}