{"id":1198,"date":"2019-06-02T10:12:30","date_gmt":"2019-06-02T02:12:30","guid":{"rendered":"https:\/\/swf.com.tw\/?p=1198"},"modified":"2019-06-02T10:12:32","modified_gmt":"2019-06-02T02:12:32","slug":"python%e7%9a%84%e9%9d%9e%e9%98%bb%e5%a1%9e%e5%bc%8f%ef%bc%88non-blocking%ef%bc%89socket%e9%80%9a%e8%a8%8a%e7%a8%8b%e5%bc%8f%ef%bc%88%e4%b8%80%ef%bc%89","status":"publish","type":"post","link":"https:\/\/swf.com.tw\/?p=1198","title":{"rendered":"Python\u7684\u975e\u963b\u585e\u5f0f\uff08non-blocking\uff09socket\u901a\u8a0a\u7a0b\u5f0f\uff08\u4e00\uff09"},"content":{"rendered":"<p>\u300a<a href=\"\/?p=1129\" target=\"_blank\" rel=\"noopener noreferrer\">\u8d85\u5716\u89e3Python\u7269\u806f\u7db2\u5be6\u4f5c\u5165\u9580<\/a>\u300b\u7b2c16-20\u9801\u63d0\u5230\uff0csocket\u7684\u65b9\u6cd5\u90fd\u5c6c\u65bc<strong>\u963b\u65b7\u5f0f\uff08block\uff09<\/strong>\u6558\u8ff0\uff0c\u4ee5\u5e95\u4e0b\u7684\u7a0b\u5f0f\u70ba\u4f8b\uff0c\u7a0b\u5f0f\u57f7\u884c\u5230&#8221;a&#8221;\u884c\u5c31\u585e\u4f4f\u4e86\u3002\u672c\u6587\u5c07\u88dc\u5145\u8aaa\u660e\u628asocket\u8a2d\u5b9a\u6210\u300c\u975e\u963b\u585e\u300d\u7684\u7a0b\u5f0f\u5beb\u6cd5\u3002<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" src=\"\/images\/books\/micropython\/socket_block.png\" width=\"647\" height=\"247\" alt=\"socket\u9020\u6210\u963b\u585e\"\/><\/p>\n<p>\u9996\u5148\u4ee5\u300c\u52d5\u624b\u4f5c16-1\uff1a\u4e00\u5c0d\u4e00\u901a\u8a0a\u7a0b\u5f0f\u300d\u7684server.py\u6a94\u70ba\u4f8b\uff0c\u7a0b\u5f0f\u6539\u5beb\u7684\u5169\u5927\u91cd\u9ede\uff1a<\/p>\n<ul>\n<li>\u628asocket\u8a2d\u6210\u300c\u975e\u963b\u585e\u300d\u6a21\u5f0f<\/li>\n<li>\u5141\u8a31\u591a\u4eba\u9023\u7dda<\/li>\n<\/ul>\n<p>\u5982\u540c\u66f8\u672c\u7b2c16-19\u9801\u8aaa\u660e\uff0c\u4f3a\u670d\u5668\u7aefsocket\u7269\u4ef6\u5c07\u5075\u807d\u7528\u6236\u7aef\u9023\u7dda\u8acb\u6c42\uff0c\u9019\u500bsocket\u76f8\u7576\u65bc\u300c\u7e3d\u6a5f\u300d\uff1b<strong>\u63a5\u53d7\uff08accept\uff09<\/strong>\u7528\u6236\u7aef\u9023\u7dda\u5f8c\uff0c\u4f3a\u670d\u5668\u5c07\u52d5\u614b\u7522\u751f\u4e00\u500b\u8207\u8a72\u7528\u6236\u901a\u4fe1\u7684socket\u7269\u4ef6\uff0c\u6b64\u8209\u76f8\u7576\u65bc\u300c\u7e3d\u6a5f\u300d\u628a\u96fb\u8a71\u8f49\u7d66\u67d0\u5c08\u4eba\u4f86\u670d\u52d9\u5ba2\u6236\u3002<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" src=\"\/images\/books\/micropython\/socket.png\" width=\"661\" height=\"246\" alt=\"socket\u901a\u8a0a\u7269\u4ef6\u5716\u8aaa\"\/><\/p>\n<p>\u7576\u6709\u65b0\u7684\u7528\u6236\u7aef\u8acb\u6c42\u9023\u7dda\u6642\uff0c\u540c\u6a23\u7531\u300c\u7e3d\u6a5f\u300d\u63a5\u7dda\u4e26\u8f49\u4ea4\u7d66\u65b0\u7522\u751f\u7684socket\u7269\u4ef6\u8655\u7406\u3002\u5f8c\u9762\u7684\u7a0b\u5f0f\u5c07\u5ba3\u544a\u4e00\u500b\u5217\u8868\u8b8a\u6578\u4f86\u66ab\u5b58\u52d5\u614b\u7522\u751f\u7684socket\u7269\u4ef6\uff0c\u65b9\u4fbf\u900f\u904e\u8ff4\u5708\u8655\u7406\u5168\u90e8\u9023\u7dda\u7528\u6236\u7684\u901a\u8a0a\u3002<\/p>\n<h2>\u4f7f\u7528setblocking()\u65b9\u6cd5\u53d6\u6d88socket\u7684\u963b\u585e\u72c0\u614b<\/h2>\n<p>\u8981\u53d6\u6d88socket\u9810\u8a2d\u7684\u963b\u585e\u72c0\u614b\uff0c\u8acb\u57f7\u884csocket\u7269\u4ef6\u7684setblocking()\u65b9\u6cd5\uff08\u539f\u610f\u70baset blocking\uff0c\u8a2d\u5b9a\u963b\u585e\uff09\uff0c\u4e26\u50b3\u5165False\u62160\u3002\u6539\u5beb\u4e4b\u5f8c\u7684server.py\u7a0b\u5f0f\u5982\u4e0b\uff0c\u65b0\u589e\u5f15\u7528time\u7a0b\u5f0f\u5eab\u3001\u5ba3\u544a\u4e00\u500bclients\u5217\u8868\u8b8a\u6578\u3001\u900f\u904esetblocking()\u65b9\u6cd5\u8a2d\u5b9a\u975e\u963b\u585e\uff0c\u5efa\u7acb\u4e00\u500bhello()\u81ea\u8a02\u51fd\u5f0f\uff1a<\/p>\n<pre>import socket\nimport time\n\nclients = []  # \u5132\u5b58\u7528\u6236\u7aefsocket\u7269\u4ef6\u7684\u5217\u8868\u8b8a\u6578\nHOST = 'localhost'\nPORT = 5438\ns = socket.socket()\ns.bind((HOST, PORT))\ns.setblocking(False)  # \u5c07\u6b64socket\u8a2d\u6210\u975e\u963b\u585e\ns.listen(5)\nprint('{}\u4f3a\u670d\u5668\u5728{}\u57e0\u958b\u901a\u4e86\uff01'.format(HOST, PORT))\n\ndef hello():\n    time.sleep(1)\n    print('\u4f60\u597d\uff01')\n<\/pre>\n<p>\u82e5while\u8ff4\u5708\u7a0b\u5f0f\u4e0d\u505a\u4efb\u4f55\u4fee\u6539\uff1a<\/p>\n<pre>while True:\n    client, addr = s.accept()\n    print('\u7528\u6236\u7aef\u4f4d\u5740\uff1a{}\uff0c\u57e0\u865f\uff1a{}'.format(addr[0], addr[1]))\n      :  \u4ee5\u4e0b\u7701\u7565\u2026\n<\/pre>\n<p>\u57f7\u884c\u6b64server.py\u6642\uff0c\u5c07\u51fa\u73fe\u5e95\u4e0b\u7684<strong>BlockingIOError\uff08\u963b\u585eIO\u932f\u8aa4\uff09<\/strong>\u8a0a\u606f\uff1a<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" src=\"\/images\/books\/micropython\/socket_error.png\" width=\"677\" height=\"230\" alt=\"BlockingIOError\uff08\u963b\u585eIO\u932f\u8aa4\uff09\"\/><\/p>\n<p>\u539f\u672c\u61c9\u8a72\u505c\u5728s.accept()\u90a3\u4e00\u884c\uff0c\u7b49\u5230\u6709\u7528\u6236\u7aef\u9023\u7dda\u518d\u81ea\u52d5\u7e7c\u7e8c\u57f7\u884c\u5f8c\u9762\u7684\u6558\u8ff0\uff0c\u56e0socket\u7269\u4ef6\uff08s\uff09\u88ab\u8a2d\u5b9a\u6210\u4ee5\u300c\u975e\u963b\u585e\u300d\u65b9\u5f0f\u57f7\u884c\uff0c\u5c0e\u81f4\u7a0b\u5f0f\u6c92\u6709\u505c\u4f4f\u3002\u5728\u6c92\u6709\u7528\u6236\u7aef\u9023\u7dda\u7684\u60c5\u6cc1\u4e0b\uff0c\u5f37\u7f6e\u57f7\u884caccept()\uff0c\u5c31\u6703\u51fa\u73fe\u5982\u4e0a\u5716\u7684\u932f\u8aa4\u3002<\/p>\n<p>\u89e3\u6c7a\u7684\u65b9\u6cd5\u662f\u7528try\u2026except\u5305\u88dd\u53ef\u80fd\u6703\u51fa\u932f\u7684\u6558\u8ff0\u3002socket\u7269\u4ef6\u7684recv\uff08\u63a5\u6536\u8a0a\u606f\uff09\u65b9\u6cd5\u9810\u8a2d\u4e5f\u6703\u9020\u6210\u963b\u585e\uff0c\u7576socket\u7269\u4ef6\u6539\u6210\u975e\u963b\u585e\u4e4b\u5f8c\uff0c\u5728\u5c1a\u672a\u6536\u5230\u7528\u6236\u7aef\u8a0a\u606f\u6642\u5f37\u7f6e\u57f7\u884crecv()\u5c07\u9020\u6210\u932f\u8aa4\uff0c\u56e0\u6b64\u4e5f\u8981\u7528try\u2026except\u5305\u88dd\u3002\u4fee\u6539\u5f8c\u7684while\u8ff4\u5708\u5982\u4e0b\uff1a<\/p>\n<pre>while True:\n    try:\n        client, addr = s.accept()\n        print('\u7528\u6236\u7aef\u4f4d\u5740\uff1a{}\uff0c\u57e0\u865f\uff1a{}'.format(addr[0], addr[1]))\n        # \u4e5f\u628a\u8ddf\u7528\u6236\u7aef\u9023\u7dda\u7684socket\u8a2d\u6210\u300c\u975e\u963b\u585e\u300d\n        client.setblocking(False) \n        # \u5c07\u6b64\u7528\u6236\u7aefsocket\u7269\u4ef6\u5b58\u5165clients\u5217\u8868\u5099\u7528\n        clients.append(client)\n    except:\n        pass  # \u4e0d\u7406\u6703\u932f\u8aa4\n\n    # \u9010\u4e00\u8655\u7406clients\u5217\u8868\u88e1\u7684\u6bcf\u500b\u7528\u6236\u7aefsocket\u2026\n    for client in clients:\n        try:\n            msg = client.recv(100).decode('utf8')\n            print('\u6536\u5230\u8a0a\u606f\uff1a' + msg)\n            reply = ''\n\n            if msg == '\u4f60\u597d':\n                reply = b'Hello!'\n            elif msg == '\u518d\u898b':\n                client.send(b'quit')\n                client.close()\n                # \u5c07\u6b64\u7528\u6236\u7aefsocket\u5f9e\u5217\u8868\u4e2d\u79fb\u9664\n                clients.remove(client)\n                break  # \u9000\u51fafor\u8ff4\u5708\n            else:\n                reply = b'what??'\n\n            client.send(reply)\n        except:\n            pass  # \u4e0d\u7406\u6703\u932f\u8aa4\n\n    # \u8655\u7406socket\u7269\u4ef6\u7a0b\u5f0f\u4e4b\u9918\uff0c\u57f7\u884c\u5176\u4ed6\u7a0b\u5f0f\u78bc\u2026\n    hello()\n<\/pre>\n<p>\u57f7\u884c\u6b64\u4f3a\u670d\u5668socket\u7a0b\u5f0f\u7684\u7d50\u679c\u5982\u4e0b\uff0c\u5b83\u5c07\u6bcf\u9694\u4e00\u79d2\u5728\u7d42\u7aef\u6a5f\u986f\u793a\u201c\u4f60\u597d\u201d\uff0c\u4e26\u4e14\u53ef\u4ee5\u8655\u7406\u7528\u6236\u7aef\u7684\u9023\u7dda\u8acb\u6c42\u3002<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" src=\"\/images\/books\/micropython\/socket_server.png\" width=\"674\" height=\"201\" alt=\"server.py\u7a0b\u5f0f\u7684\u57f7\u884c\u756b\u9762\"\/><\/p>\n<h2>\u975e\u963b\u585esocket\u7684MicroPython\u7db2\u7ad9\u4f3a\u670d\u5668\u7a0b\u5f0f<\/h2>\n<p>\u5e95\u4e0b\u662f\u904b\u7528\u540c\u6a23\u624b\u6cd5\u6539\u5beb17-2\u9801\u7684MicroPython\u7db2\u7ad9\u4f3a\u670d\u5668\u7a0b\u5f0f\uff1a<\/p>\n<pre>import socket\nimport time\n\nclients = []\ns = socket.socket()\nHOST = '0.0.0.0'\nPORT = 80\nhttpHeader = b\"\"\"\\\nHTTP\/1.0 200 OK\n\nWelcome to MicroPython!\n\"\"\"\n\ns.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)\ns.bind((HOST, PORT))\ns.setblocking(False)\ns.listen(5)\nprint(\"Server running on port \", PORT)\n\ndef hello():\n    time.sleep(1)\n    print('hello!')\n\nwhile True:\n    try:\n        client, addr = s.accept()\n        print(\"Client address:\", addr)\n        clients.append(client)\n    except:\n        pass\n\n    for client in clients:\n        try:\n            req = client.recv(1024)\n            print(\"Request:\")\n            print(req)\n            client.send(httpHeader)\n            client.close()\n            clients.remove(client)\n            print('-----------------------')\n        except:\n            pass\n\n    hello()\n<\/pre>\n<p>\u628a\u7a0b\u5f0f\u4e0a\u50b3\u5230\u63a7\u5236\u677f\u4e4b\u5f8c\u57f7\u884c\uff0c\u5b83\u5c07\u6bcf\u96941\u79d2\u5728\u7d42\u7aef\u6a5f\u986f\u793a\u201chello!\u201d\uff0c\u4e26\u4e14\u53ef\u4ee5\u8655\u7406\u7528\u6236\u7aef\uff08\u700f\u89bd\u5668\uff09\u7684\u9023\u7dda\u8acb\u6c42\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u540c\u66f8\u672c\u7b2c16-19\u9801\u8aaa\u660e\uff0c\u4f3a\u670d\u5668\u7aefsocket\u7269\u4ef6\u5c07\u5075\u807d\u7528\u6236\u7aef\u9023\u7dda\u8acb\u6c42\uff0c\u9019\u500bsocket\u76f8\u7576\u65bc\u300c\u7e3d\u6a5f\u300d\uff1b<strong>\u63a5\u53d7\uff08accept\uff09<\/strong>\u7528\u6236\u7aef\u9023\u7dda\u5f8c\uff0c\u4f3a\u670d\u5668\u5c07\u52d5\u614b\u7522\u751f\u4e00\u500b\u8207\u8a72\u7528\u6236\u901a\u4fe1\u7684socket\u7269\u4ef6\uff0c\u6b64\u8209\u76f8\u7576\u65bc\u300c\u7e3d\u6a5f\u300d\u628a\u96fb\u8a71\u8f49\u7d66\u67d0\u5c08\u4eba\u4f86\u670d\u52d9\u5ba2\u6236\u3002 <\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/images\/books\/micropython\/socket.png\" width=\"661\" height=\"246\" alt=\"socket\u901a\u8a0a\u7269\u4ef6\u5716\u8aaa\"\/><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","footnotes":""},"categories":[3,15],"tags":[54,49],"class_list":["post-1198","post","type-post","status-publish","format-standard","hentry","category-3","category-diy","tag-micropython","tag-python"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Python\u7684\u975e\u963b\u585e\u5f0f\uff08non-blocking\uff09socket\u901a\u8a0a\u7a0b\u5f0f\uff08\u4e00\uff09 - \u8d85\u5716\u89e3\u7cfb\u5217\u5716\u66f8<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/swf.com.tw\/?p=1198\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005:\" \/>\n\t<meta name=\"twitter:data1\" content=\"cubie\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9810\u4f30\u95b1\u8b80\u6642\u9593\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 \u5206\u9418\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/swf.com.tw\\\/?p=1198#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/swf.com.tw\\\/?p=1198\"},\"author\":{\"name\":\"cubie\",\"@id\":\"https:\\\/\\\/swf.com.tw\\\/#\\\/schema\\\/person\\\/24480fda9184aa137df8f05d79bc2f57\"},\"headline\":\"Python\u7684\u975e\u963b\u585e\u5f0f\uff08non-blocking\uff09socket\u901a\u8a0a\u7a0b\u5f0f\uff08\u4e00\uff09\",\"datePublished\":\"2019-06-02T02:12:30+00:00\",\"dateModified\":\"2019-06-02T02:12:32+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/swf.com.tw\\\/?p=1198\"},\"wordCount\":59,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/swf.com.tw\\\/#organization\"},\"keywords\":[\"MicroPython\",\"Python\"],\"articleSection\":[\"\u6559\u5b78\u6587\u4ef6\",\"\u786c\u9ad4\u8207DIY\"],\"inLanguage\":\"zh-TW\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/swf.com.tw\\\/?p=1198#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/swf.com.tw\\\/?p=1198\",\"url\":\"https:\\\/\\\/swf.com.tw\\\/?p=1198\",\"name\":\"Python\u7684\u975e\u963b\u585e\u5f0f\uff08non-blocking\uff09socket\u901a\u8a0a\u7a0b\u5f0f\uff08\u4e00\uff09 - \u8d85\u5716\u89e3\u7cfb\u5217\u5716\u66f8\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/swf.com.tw\\\/#website\"},\"datePublished\":\"2019-06-02T02:12:30+00:00\",\"dateModified\":\"2019-06-02T02:12:32+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/swf.com.tw\\\/?p=1198#breadcrumb\"},\"inLanguage\":\"zh-TW\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/swf.com.tw\\\/?p=1198\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/swf.com.tw\\\/?p=1198#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/swf.com.tw\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python\u7684\u975e\u963b\u585e\u5f0f\uff08non-blocking\uff09socket\u901a\u8a0a\u7a0b\u5f0f\uff08\u4e00\uff09\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/swf.com.tw\\\/#website\",\"url\":\"https:\\\/\\\/swf.com.tw\\\/\",\"name\":\"\u8d85\u5716\u89e3\u7cfb\u5217\u5716\u66f8\",\"description\":\"Arduino+Python+JavaScript+\u7a0b\u5f0f\u8a2d\u8a08+\u786c\u9ad4DIY\",\"publisher\":{\"@id\":\"https:\\\/\\\/swf.com.tw\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/swf.com.tw\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"zh-TW\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/swf.com.tw\\\/#organization\",\"name\":\"\u8d85\u5716\u89e3\u7cfb\u5217\u5716\u66f8\",\"url\":\"https:\\\/\\\/swf.com.tw\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-TW\",\"@id\":\"https:\\\/\\\/swf.com.tw\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/swf.com.tw\\\/wp-content\\\/uploads\\\/2019\\\/10\\\/logo_bat.png\",\"contentUrl\":\"https:\\\/\\\/swf.com.tw\\\/wp-content\\\/uploads\\\/2019\\\/10\\\/logo_bat.png\",\"width\":71,\"height\":65,\"caption\":\"\u8d85\u5716\u89e3\u7cfb\u5217\u5716\u66f8\"},\"image\":{\"@id\":\"https:\\\/\\\/swf.com.tw\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/swf.com.tw\\\/#\\\/schema\\\/person\\\/24480fda9184aa137df8f05d79bc2f57\",\"name\":\"cubie\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-TW\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/c77b6f4d3b4ccdcdc343aeee53301c212f54787c43bd2ebf6648bf74ff59b474?s=96&d=retro&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/c77b6f4d3b4ccdcdc343aeee53301c212f54787c43bd2ebf6648bf74ff59b474?s=96&d=retro&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/c77b6f4d3b4ccdcdc343aeee53301c212f54787c43bd2ebf6648bf74ff59b474?s=96&d=retro&r=g\",\"caption\":\"cubie\"},\"sameAs\":[\"https:\\\/\\\/swf.com.tw\"],\"url\":\"https:\\\/\\\/swf.com.tw\\\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Python\u7684\u975e\u963b\u585e\u5f0f\uff08non-blocking\uff09socket\u901a\u8a0a\u7a0b\u5f0f\uff08\u4e00\uff09 - \u8d85\u5716\u89e3\u7cfb\u5217\u5716\u66f8","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/swf.com.tw\/?p=1198","twitter_misc":{"\u4f5c\u8005:":"cubie","\u9810\u4f30\u95b1\u8b80\u6642\u9593":"1 \u5206\u9418"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/swf.com.tw\/?p=1198#article","isPartOf":{"@id":"https:\/\/swf.com.tw\/?p=1198"},"author":{"name":"cubie","@id":"https:\/\/swf.com.tw\/#\/schema\/person\/24480fda9184aa137df8f05d79bc2f57"},"headline":"Python\u7684\u975e\u963b\u585e\u5f0f\uff08non-blocking\uff09socket\u901a\u8a0a\u7a0b\u5f0f\uff08\u4e00\uff09","datePublished":"2019-06-02T02:12:30+00:00","dateModified":"2019-06-02T02:12:32+00:00","mainEntityOfPage":{"@id":"https:\/\/swf.com.tw\/?p=1198"},"wordCount":59,"commentCount":0,"publisher":{"@id":"https:\/\/swf.com.tw\/#organization"},"keywords":["MicroPython","Python"],"articleSection":["\u6559\u5b78\u6587\u4ef6","\u786c\u9ad4\u8207DIY"],"inLanguage":"zh-TW","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/swf.com.tw\/?p=1198#respond"]}]},{"@type":"WebPage","@id":"https:\/\/swf.com.tw\/?p=1198","url":"https:\/\/swf.com.tw\/?p=1198","name":"Python\u7684\u975e\u963b\u585e\u5f0f\uff08non-blocking\uff09socket\u901a\u8a0a\u7a0b\u5f0f\uff08\u4e00\uff09 - \u8d85\u5716\u89e3\u7cfb\u5217\u5716\u66f8","isPartOf":{"@id":"https:\/\/swf.com.tw\/#website"},"datePublished":"2019-06-02T02:12:30+00:00","dateModified":"2019-06-02T02:12:32+00:00","breadcrumb":{"@id":"https:\/\/swf.com.tw\/?p=1198#breadcrumb"},"inLanguage":"zh-TW","potentialAction":[{"@type":"ReadAction","target":["https:\/\/swf.com.tw\/?p=1198"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/swf.com.tw\/?p=1198#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/swf.com.tw\/"},{"@type":"ListItem","position":2,"name":"Python\u7684\u975e\u963b\u585e\u5f0f\uff08non-blocking\uff09socket\u901a\u8a0a\u7a0b\u5f0f\uff08\u4e00\uff09"}]},{"@type":"WebSite","@id":"https:\/\/swf.com.tw\/#website","url":"https:\/\/swf.com.tw\/","name":"\u8d85\u5716\u89e3\u7cfb\u5217\u5716\u66f8","description":"Arduino+Python+JavaScript+\u7a0b\u5f0f\u8a2d\u8a08+\u786c\u9ad4DIY","publisher":{"@id":"https:\/\/swf.com.tw\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/swf.com.tw\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"zh-TW"},{"@type":"Organization","@id":"https:\/\/swf.com.tw\/#organization","name":"\u8d85\u5716\u89e3\u7cfb\u5217\u5716\u66f8","url":"https:\/\/swf.com.tw\/","logo":{"@type":"ImageObject","inLanguage":"zh-TW","@id":"https:\/\/swf.com.tw\/#\/schema\/logo\/image\/","url":"https:\/\/swf.com.tw\/wp-content\/uploads\/2019\/10\/logo_bat.png","contentUrl":"https:\/\/swf.com.tw\/wp-content\/uploads\/2019\/10\/logo_bat.png","width":71,"height":65,"caption":"\u8d85\u5716\u89e3\u7cfb\u5217\u5716\u66f8"},"image":{"@id":"https:\/\/swf.com.tw\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/swf.com.tw\/#\/schema\/person\/24480fda9184aa137df8f05d79bc2f57","name":"cubie","image":{"@type":"ImageObject","inLanguage":"zh-TW","@id":"https:\/\/secure.gravatar.com\/avatar\/c77b6f4d3b4ccdcdc343aeee53301c212f54787c43bd2ebf6648bf74ff59b474?s=96&d=retro&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/c77b6f4d3b4ccdcdc343aeee53301c212f54787c43bd2ebf6648bf74ff59b474?s=96&d=retro&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c77b6f4d3b4ccdcdc343aeee53301c212f54787c43bd2ebf6648bf74ff59b474?s=96&d=retro&r=g","caption":"cubie"},"sameAs":["https:\/\/swf.com.tw"],"url":"https:\/\/swf.com.tw\/?author=1"}]}},"_links":{"self":[{"href":"https:\/\/swf.com.tw\/index.php?rest_route=\/wp\/v2\/posts\/1198","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/swf.com.tw\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/swf.com.tw\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/swf.com.tw\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/swf.com.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1198"}],"version-history":[{"count":0,"href":"https:\/\/swf.com.tw\/index.php?rest_route=\/wp\/v2\/posts\/1198\/revisions"}],"wp:attachment":[{"href":"https:\/\/swf.com.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1198"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/swf.com.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1198"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/swf.com.tw\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1198"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}