{"id":321529,"date":"2021-02-05T13:11:45","date_gmt":"2021-02-05T05:11:45","guid":{"rendered":"http:\/\/4563.org\/?p=321529"},"modified":"2021-02-05T13:11:45","modified_gmt":"2021-02-05T05:11:45","slug":"%e8%af%b7%e9%97%ae%e4%b8%80%e4%b8%aa-python-socket-%e7%9a%84%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=321529","title":{"rendered":"\u8bf7\u95ee\u4e00\u4e2a Python Socket \u7684\u95ee\u9898"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u8bf7\u95ee\u4e00\u4e2a Python Socket \u7684\u95ee\u9898               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : deplives <\/span>  <span><i><\/i> 7<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u548c\u670d\u52a1\u7aef\u91c7\u7528 socket \u94fe\u63a5\uff0c\u672c\u5730\u521b\u5efa\u4e00\u4e2a\u7ebf\u7a0b\u901a\u8fc7 <code>while True: socket.recv(1024)<\/code> \u6765\u63a5\u53d7\u6570\u636e\uff0c\u4f46\u662f\u6709\u4e00\u6b21\u53d1\u73b0\uff0c\u67d0\u4e2a\u6570\u636e\u63a5\u53d7\u4e0d\u5230\uff0c\u670d\u52a1\u7aef\u8bf4\u4ed6\u786e\u5b9a\u53d1\u4e86\uff0c\u6211\u4e5f\u786e\u5b9a\u6211\u90fd\u6536\u4e86\uff0c\u7136\u540e\u6293\u4e86\u4e0b\u5305\u53d1\u73b0\u670d\u52a1\u7aef\u4e24\u6b21 send \u4e2d\u95f4\u53ea\u9694\u4e86 0.004ms \u8c8c\u4f3c\u662f\u56e0\u4e3a\u8fd9\u4e2a\u539f\u56e0\u5bfc\u81f4\u7b2c\u4e8c\u5e27\u6570\u636e\u65e0\u6cd5\u901a\u8fc7 <code>recv()<\/code> \u63a5\u6536\u5230\uff0c\u8bf7\u95ee\u4e0b\u8fd9\u79cd\u60c5\u51b5\u4e0b\u6211\u8be5\u600e\u4e48\u5904\u7406<\/p>\n<p>\u6211\u8fd9\u4e2a recv \u7684\u7ebf\u7a0b\u53ea\u6709\u4e00\u4ef6\u4e8b\u513f\uff0crecv \u6536\u5230\u6570\u636e\uff0c\u7136\u540e push \u5230\u4e00\u4e2a\u6d88\u8d39\u961f\u5217\uff0c\u6211\u5b9e\u9645\u6d4b\u4e86\u4e00\u4e0b\uff0c\u6211\u4ec5\u4ec5 recv \u5c31\u5dee\u4e0d\u591a\u8981 4ms \u8fd9\u4e2a\u5230\u5e95\u8be5\u600e\u4e48\u73a9<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>11<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"5005152\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Pagliacii <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u611f\u89c9\u53ef\u4ee5\u628a\u6570\u636e\u5b58\u5230\u4e00\u4e2a Buffer \u91cc\uff0c\u6ee1\u4e86\u518d\u505a\u5904\u7406                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5005153\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ysc3839 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4f60\u7528\u7684\u662f TCP \u5417\uff1f TCP \u662f\u6d41\u5f0f\u4f20\u8f93\u7684\uff0c\u6ca1\u6709\u201c\u5e27\u201d\u7684\u6982\u5ff5\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5005154\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : opengps <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u627e\u627e\u662f\u4e0d\u662f\u88ab\u62c6\u5305\u8fc7\u7a0b\u4e2d\u629b\u5f03\u4e86\u3002\u629b\u5f03\u903b\u8f91\u5176\u5b9e\u633a\u591a\u7684\uff0c\u4e0d\u7b26\u5408\u534f\u8bae\u7ed3\u6784\u7684\uff0c\u7c98\u5305\u7684\u7b49\u7b49                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5005155\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : shyrock <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u53d1\u9001\u548c\u63a5\u6536\u7684\u4ee3\u7801\u8d34\u4e00\u4e0b\u3002\u80af\u5b9a\u4e0d\u662f\u53d1\u9001\u592a\u5feb\u7684\u95ee\u9898\uff0c\u4f60\u8fd9\u6837\u8bf4\u591a\u4e2a\u5ba2\u6237\u7aef\u5e76\u53d1\u8fde\u63a5\u5c31\u6ca1\u6cd5\u641e\u4e86\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5005156\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : unixeno <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u7c98\u5305\u8b66\u5bdf\u8b66\u544a                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5005157\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : tomemi <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             TCP \u7c98\u5305                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5005158\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Jirajine <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             tcp \u4e0d\u662f\u4f60\u8fd9\u6837\u7528\u7684\u3002<br \/>\u4f60\u5e94\u8be5\u5199\u4e2a\u7c7b\uff0c\u628a tcp \u8fde\u63a5\u5305\u88c5\u8fdb\u53bb\uff0c\u7136\u540e\u5b9e\u73b0\u4e00\u4e2a read \u65b9\u6cd5\u3002<br \/>\u5185\u90e8\u6bcf\u6b21\u8c03\u7528 read \u65f6\u4ece tcp \u6d41\u8bfb\u6570\u636e\uff0c\u8bfb\u591f\u6b63\u597d\u4e00\u4e2a\u5bf9\u8c61\u7136\u540e\u53cd\u5e8f\u5217\u5316\u540e\u8fd4\u56de\u8fd9\u4e2a\u5bf9\u8c61\u3002<br \/>\u5728\u5916\u5c42\u53ef\u4ee5\u5faa\u73af\u8c03\u7528 read\uff0c\u6bcf\u6b21\u83b7\u5f97\u4e00\u4e2a\u5bf9\u8c61\u518d\u8fdb\u884c\u5176\u4ed6\u5904\u7406\u3002<br \/>\u81f3\u4e8e\u5176\u4ed6\u7684\u4f18\u5316\u5957\u4e2a bufferedreader \u4e4b\u7c7b\u7684\u5c31\u6ca1\u4ec0\u4e48\u597d\u8bf4\u7684\u4e86\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5005159\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : deplives <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @unixeno \u628a\u65e5\u5fd7\u91cd\u65b0\u635e\u4e86\u4e00\u904d\uff0c\u786e\u5b9e\u662f\u7c98\u5305\u4e86\uff0c\u95ee\u9898\u5df2\u7ecf\u89e3\u51b3 \u611f\u8c22                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5005160\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : nightwitch <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             tcp \u6ca1\u6709\u5e27\u7684\u6982\u5ff5                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5005161\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : todd7zhang <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u7ea6\u5b9a\u53d1 [length][body], \u5b9a\u6b7b length \u5360\u7528\u51e0\u4e2a\u5b57\u8282\u5c31\u597d\u4e86\uff01\u4e16\u4e0a\u54ea\u6709\u7c98\u5305\uff0c\u62c6\u5305                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5005162\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Leigg <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5c0f\u4f19\u5b50\u4e0d\u8981\u9493\u9c7c\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u8bf7\u95ee\u4e00\u4e2a Python Socke&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/321529"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=321529"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/321529\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=321529"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=321529"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=321529"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}