{"id":2502,"date":"2019-05-27T08:45:50","date_gmt":"2019-05-27T08:45:50","guid":{"rendered":""},"modified":"2019-05-27T16:46:26","modified_gmt":"2019-05-27T08:46:26","slug":"%e5%9f%ba%e4%ba%8e%e6%a0%91%e8%8e%93%e6%b4%be%e7%9a%84%e4%b8%b2%e5%8f%a3%e6%9c%8d%e5%8a%a1%e5%99%a8%e8%ae%be%e8%ae%a1","status":"publish","type":"post","link":"http:\/\/www.szryc.com\/?p=2502","title":{"rendered":"\u57fa\u4e8e\u6811\u8393\u6d3e\u7684\u4e32\u53e3\u670d\u52a1\u5668\u8bbe\u8ba1"},"content":{"rendered":"
\n\t\u5de5\u4e1a\u63a7\u5236\u4e2d\uff0c\u5404\u8bbe\u5907\u7684\u4fe1\u53f7\u91c7\u96c6\u548c\u76d1\u63a7\u53ea\u9760\u4e32\u53e3\u603b\u7ebf\u96be\u4ee5\u5b9e\u73b0\u6269\u5c55\uff0c\u8981\u5c06\u73b0\u573a\u63a7\u5236\u7f51\u7edc\u548c\u4fe1\u606f\u7f51\u7edc\u76f8\u8fde\uff0c\u5c31\u9700\u8981\u89e3\u51b3\u4e32\u53e3\u901a\u4fe1\u534f\u8bae\u548c\u56e0\u7279\u7f51\u901a\u4fe1\u534f\u8bae\u7684\u8f6c\u6362\u95ee\u9898\uff0c\u5373\u628a\u539f\u6709\u8bbe\u5907\u8f6c\u6362\u4e3a\u5177\u5907\u7f51\u7edc\u63a5\u53e3\u7684\u5916\u8bbe\uff0c\u8fd9\u6837\u53ef\u4ee5\u5c06\u4f20\u7edf\u4e32\u884c\u94fe\u8def\u4e0a\u7684\u6570\u636e\u4f20\u8f93\u5230\u4fe1\u606f\u7f51\u7edc\u4e0a\uff0c\u800c\u65e0\u9700\u66f4\u6362\u539f\u6709\u8bbe\u5907\u3002\u5982\u6b64\uff0c\u53ef\u4ee5\u63d0\u9ad8\u539f\u6709\u8bbe\u5907\u5229\u7528\u7387\u3001\u589e\u52a0\u591a\u7ec8\u7aef\u8fde\u63a5\u6570\u3001\u8282\u7ea6\u6210\u672c\u3001\u7b80\u5316\u5e03\u7ebf<\/u>\u7684\u590d\u6742\u5ea6\u53ca\u5ef6\u957f\u901a\u4fe1\u8ddd\u79bb\u3002<\/p>\n
\n\t\u8fd1\u5e74\u6765\uff0c\u56e0\u4fe1\u606f\u5316\u548c\u7269\u8054\u7f51\u53d1\u5c55\u7684\u9700\u8981\uff0c\u4e32\u53e3\u670d\u52a1\u5668\u5927\u91cf\u6d8c\u73b0\uff0c\u5b83\u4eec\u4e0d\u5360\u7528\u4e3b\u673a\u8d44\u6e90\uff0c\u4e14\u5177\u6709\u7ec8\u7aef\u670d\u52a1\u5668\u7684\u529f\u80fd\u3002\u4e0d\u8fc7\uff0c\u8bbe\u5907\u4f53\u79ef\u5e9e\u5927\u3001\u4ef7\u683c\u6602\u8d35\u3001\u4e32\u53e3\u4e0d\u6613\u88c1\u526a\u6216\u6269\u5c55\u3001\u4f20\u8f93\u5927\u91cf\u6570\u636e\u5e27\u65f6\u4e22\u5305\u3001\u53c2\u6570\u914d\u7f6e\u7e41\u6742\u7b49\u95ee\u9898\u4e5f\u968f\u4e4b\u51fa\u73b0\u3002<\/p>\n
\n\t\u672c\u8bbe\u8ba1\u91c7\u7528\u7684\u4e32\u53e3\u670d\u52a1\u5668\u7684\u6838\u5fc3\u8bbe\u5907--\u6811\u8393\u6d3e<\/u>\uff0c\u662f\u4e00\u6b3e\u4f53\u79ef\u5c0f\u3001\u4ef7\u683c\u4fbf\u5b9c\u4f46\u529f\u80fd\u975e\u5e38\u5f3a\u5927\u7684\u5e73\u53f0\uff0c\u53ef\u901a\u8fc7\u591a\u79cd\u901a\u4fe1\u65b9\u5f0f\u63a5\u5165\u4e92\u8054\u7f51\uff0c\u652f\u6301\u591a\u79cd\u5b8c\u6574\u7f51\u7edc\u534f\u8bae\uff0c\u7ed3\u5408USB<\/u>-hub\u53caUSB\/\u4e32\u53e3\u8f6c\u6362\u5668\u4f7f\u7528\uff0c\u53ef\u4fdd\u8bc1\u4e32\u53e3\u670d\u52a1\u5668\u4f7f\u7528\u65b9\u4fbf\uff0c\u5e76\u5b9e\u73b0\u5b9e\u65f6\u3001\u51c6\u786e\u3001\u957f\u65f6\u95f4\u7a33\u5b9a\u7684\u6570\u636e\u4f20\u8f93\u3002<\/p>\n
\n\t1 \u603b\u4f53\u8bbe\u8ba1<\/p>\n
\n\t\u6839\u636e\u5f53\u4eca\u5de5\u4e1a\u73b0\u573a\u6570\u636e\u4f20\u8f93\u9700\u6c42\uff0c\u5e94\u5177\u5907\u7684\u6280\u672f\u6307\u6807\u548c\u8bbe\u7f6e\u53c2\u6570\u5982\u4e0b\u3002<\/p>\n
\n\t1.1 \u6280\u672f\u6307\u6807<\/p>\n
\n\t\u2460\u4e3b\u63a7\u82af\u7247\uff1a32\u4f4d700 MHz\u7684ARM<\/u>1176JZF-S\u5904\u7406\u5668;<\/p>\n
\n\t\u2461\u64cd\u4f5c\u7cfb\u7edf\uff1aLinux<\/u>;<\/p>\n
\n\t\u2462\u652f\u6301\u534f\u8bae\uff1aTCP\/IP\u3001UDP\u3001HTTP\u3001FTP;<\/p>\n
\n\t\u2463\u7f51\u7edc\u63a5\u53e3\uff1a10\/100 Mbps\u81ea\u9002\u5e94\u4ee5\u592a\u7f51<\/u>\u63a5\u53e3;<\/p>\n
\n\t\u2464\u4e32\u53e3\u7c7b\u578b\uff1a1\uff5e16\u4e2aRS<\/u> 232\/RS485\/RS422\u63a5\u53e3\uff0c1\u4e2aTTL\u7535\u5e73\u4e32\u53e3;<\/p>\n
\n\t\u2465\u53c2\u6570\u914d\u7f6e\u65b9\u5f0f\uff1aWEB\u6d4f\u89c8\u5668\u914d\u7f6e;<\/p>\n
\n\t\u2466\u4f1a\u8bdd\u6570\uff1a\u652f\u6301\u591a\u8fde\u63a5\uff0c\u6ee1\u8db35\u4e2a\u4ee5\u5185\u7528\u6237\u540c\u65f6\u7ba1\u7406\u4e00\u4e2a\u6a21\u5757\u8bbe\u5907;<\/p>\n
\n\t\u2467\u5de5\u4f5c\u6a21\u5f0f\uff1aTCP\u5ba2\u6237\u7aef\u3001TCP\u670d\u52a1\u5668\u3001UDP\u5e7f\u64ad\u6a21\u5f0f;<\/p>\n
\n\t\u2468\u6307\u793a\u706f\uff1a\u7535\u6e90\u6307\u793a\u706f\u3001\u901a\u4fe1\u6307\u793a\u706f;<\/p>\n
\n\t\u2469\u4f9b\u7535\u7535\u538b\uff1a5 V\u3002<\/p>\n
\n\t1.2 \u8bbe\u7f6e\u53c2\u6570<\/p>\n
\n\t\u8be5\u8bbe\u5907\u9009\u62e9WEB\u6d4f\u89c8\u5668\u8bbe\u7f6e\u65b9\u5f0f\uff0c\u5185\u7f6eWEB\u670d\u52a1\u5668\uff0c\u7528\u6237\u53ef\u8fdb\u884cIP\u5730\u5740\u3001\u4e32\u53e3\u901a\u4fe1\u53c2\u6570\u3001\u5de5\u4f5c\u6a21\u5f0f\u7b49\u7684\u7ba1\u7406\u548c\u914d\u7f6e\u3002\u4ee5\u4e0b\u4e3b\u8981\u4ecb\u7ecd\u4e32\u53e3\u901a\u4fe1\u548c\u5de5\u4f5c\u6a21\u5f0f\u53c2\u6570\u7684\u8bbe\u7f6e\u3002<\/p>\n
\n\t(1)\u4e32\u53e3\u901a\u4fe1\u53c2\u6570<\/p>\n
\n\t\u2460\u6ce2\u7279\u7387\u4e3a2 400\uff5e115 200 bps;<\/p>\n
\n\t\u2461\u6570\u636e\u4f4d\u4e3a6\/7\/8\/9;<\/p>\n
\n\t\u2462\u6821\u9a8c\u4f4d\u4e3aNone\/Even\/Odd;<\/p>\n
\n\t\u2463\u505c\u6b62\u4f4d\u4e3a1\/1.5\/2;<\/p>\n
\n\t\u2464\u6210\u5e27\u957f\u5ea6\u4e3a1\uff5e15000\u5b57\u8282;<\/p>\n
\n\t\u2465\u6210\u5e27\u95f4\u9694\u4e3a30\uff5e500\u4f4d\u3002<\/p>\n
\n\t\u5176\u4e2d\uff0c\u6210\u5e27\u957f\u5ea6\u6307\u6bcf\u4e00\u5e27\u63a5\u6536\u6570\u636e\u7684\u957f\u5ea6\uff0c\u63a5\u6536\u7aef\u7f13\u51b2\u533a\u4e00\u65e6\u63a5\u6536\u5230\u8be5\u957f\u5ea6\u7684\u6570\u636e\u5c31\u8f6c\u53d1\u51fa\u53bb;\u6210\u5e27\u95f4\u9694\u5c31\u662f\u6240\u8c13\u7684\u4e32\u53e3\u8d85\u65f6\uff0c\u8d85\u65f6\u65f6\u95f4T(s)\u3001\u6210\u5e27\u95f4\u9694N(\u4f4d)\u3001\u6ce2\u7279\u7387B(b\/s)\u7684\u5173\u7cfb\u5982\u4e0b\u3002\u4e00\u65e6\u8d85\u65f6\uff0c\u4e0d\u7ba1\u5df2\u6709\u6570\u636e\u957f\u5ea6\u662f\u4e0d\u662f\u8fbe\u5230\u6210\u5e27\u957f\u5ea6\uff0c\u63a5\u6536\u7aef\u7f13\u51b2\u533a\u5c31\u5c06\u5df2\u6709\u6570\u636e\u7ec4\u5e27\u8f6c\u53d1\u51fa\u53bb\u3002<\/p>\n
\n\tT= N\/B (1)<\/p>\n
\n\t(2)\u5de5\u4f5c\u6a21\u5f0f\u53c2\u6570<\/p>\n
\n\t\u2460\u5355\u4e2a\u4e32\u53e3\u652f\u6301\u4f1a\u8bdd\u6570\u4e3a1\uff5e5\u4e2a\uff0c\u6bcf\u4e2a\u4f1a\u8bdd\u6a21\u5f0f\u95f4\u76f8\u4e92\u72ec\u7acb;<\/p>\n
\n\t\u2461TCP\u670d\u52a1\u5668\u6a21\u5f0f\u4e3a\u7ed1\u5b9a\u7aef\u53e3\u8303\u56f4\u4e3a1025\uff5e65535;<\/p>\n
\n\t\u2462TCP\u5ba2\u6237\u7aef\u6a21\u5f0f\u4e3a\u9700\u914d\u7f6e\u76ee\u6807\u670d\u52a1\u5668IP\u3001\u7aef\u53e3\u53ca\u81ea\u52a8\u91cd\u8fde\u65f6\u95f4\uff0c\u5176\u4e2d\u81ea\u52a8\u91cd\u8fde\u65f6\u95f4\u6307\u7f51\u7edc\u8fde\u63a5\u4e2d\u65ad\u6216\u8005\u670d\u52a1\u5668\u5f02\u5e38\u65f6\uff0c\u91cd\u65b0\u53d1\u8d77\u4e3b\u52a8\u8fde\u63a5\u7684\u65f6\u95f4\u95f4\u9694\uff0c\u5faa\u73af\u81ea\u52a8\u91cd\u8fde\u76f4\u5230\u6b63\u5e38\u8fde\u63a5\u4e0a\u4e3a\u6b62;<\/p>\n
\n\t\u2463UDP\u5e7f\u64ad\u6a21\u5f0f\u4e3a\u9700\u914d\u7f6e\u672c\u5730\u7aef\u53e3\u3001\u76ee\u6807\u670d\u52a1\u5668IP\u548c\u76ee\u6807\u7aef\u53e3\u3002<\/p>\n
\n\t2 \u786c\u4ef6\u8bbe\u8ba1<\/p>\n
\n\t\u6b64\u4e32\u53e3\u670d\u52a1\u5668\u6839\u636e\u4ee5\u4e0a\u6307\u6807\u9009\u7528\u6700\u65b0\u7684\u6811\u8393\u6d3e\u3001USB-hub\u53ca\u5317\u4eac\u4e16\u7eaa\u8054\u4fe1\u516c\u53f8\u751f\u4ea7\u7684USB\/\u56db\u4e32\u53e3\u8f6c\u6362\u5668\u7ec4\u5408\u800c\u6210\u3002<\/p>\n
\n\t2.1 \u786c\u4ef6\u7ed3\u6784\u7ec4\u6210<\/p>\n
\n\t\u4e32\u53e3\u670d\u52a1\u5668\u786c\u4ef6\u7ed3\u6784\u7ec4\u6210\u5982\u56fe1\u6240\u793a\uff0c\u6811\u8393\u6d3e\u5177\u6709\u4e24\u4e2aUSB\u63a5\u53e3\u3001\u4e00\u4e2aTTL\u4e32\u53e3\u53ca\u4e00\u4e2a10\/100 MHz\u81ea\u9002\u5e94\u4ee5\u592a\u7f51\u63a5\u53e3\u3002\u4e00\u4e2aUSB\u63a5\u53e3\u901a\u8fc7USB-hub\u548cn(\u53ef\u636e\u60c5\u51b5\u9009\u62e9\uff0c\u6700\u591a\u65f6n=4)\u4e2aUSB\/\u4e32\u53e3\u8f6c\u6362\u5668\u6269\u5c55\u51fa4n\u4e2aRS232\/RS422\/RS455\u4e32\u53e3\uff0c\u53e6\u4e00\u4e2a\u53ef\u5916\u63a5\u65e0\u7ebfUSB\u7f51\u5361\uff0c\u4ece\u800c\u5b9e\u73b0\u5c40\u57df\u7f51\u6216\u5e7f\u57df\u7f51\u4e2d\u6709\u7ebf\u6216\u65e0\u7ebf\u6570\u636e\u4f20\u8f93\u3002<\/p>\n
\n\t<\/p>\n
\n\t\u56fe1 \u786c\u4ef6\u7ed3\u6784\u6846\u56fe<\/p>\n
\n\t2.2 \u6811\u8393\u6d3e\u7b80\u4ecb<\/p>\n
\n\t\u6811\u8393\u6d3e(Raspberry Pi<\/u>)\u662f\u4e00\u6b3e\u57fa\u4e8eLinux\u7cfb\u7edf\u7684\u53ea\u6709\u4e00\u5f20\u4fe1\u7528\u5361\u5927\u5c0f\u7684\u5355\u677f\u8ba1\u7b97\u673a\uff0c\u914d\u5907\u4e00\u679a\u535a\u901a<\/u>\u751f\u4ea7\u7684700 MHzARM\u67b6\u6784BCM2835\u5904\u7406\u5668\uff0c512 MB\u5185\u5b58\uff0c\u4f7f\u7528SD\u5361\u5f53\u4f5c\u5b58\u50a8\u4ecb\u8d28\uff0c\u64cd\u4f5c\u7cfb\u7edf\u91c7\u7528\u5f00\u6e90\u7684Linux\u7cfb\u7edf\uff0c\u63d0\u4f9b\u5e76\u652f\u6301Python<\/u>\u4f5c\u4e3a\u4e3b\u8981\u7f16\u7a0b\u8bed\u8a00\u3002<\/p>\n
\n\t2.3 USB-hub\u7b80\u4ecb<\/p>\n
\n\tUSB-hub(USB\u96c6\u7ebf\u5668)\u662f\u4e00\u4e2a\u5c06\u591a\u4e2aUSB\u8bbe\u5907\u8fde\u63a5\u5230\u8ba1\u7b97\u673a\u4e0a\u7684USB\u63a5\u53e3\u6216\u53e6\u4e00\u4e2aUSB\u96c6\u7ebf\u5668\u4e0a\u67d0\u65f6\u5019\uff0c\u5b83\u4eec\u90fd\u6765\u81ea\u4e8e\u4e3b\u677f\u5185\u90e8\u4e00\u4e2a\u6216\u8005\u4e24\u4e2a\u4e3bUSB\u63a5\u53e3\uff0c\u800c\u4e0d\u662f\u76f8\u4e92\u72ec\u7acb\u7684\u786c\u4ef6\u3002\u4e00\u4e2aUSB\u63a5\u53e3\u3001\u4e00\u4e2aUSB\u96c6\u7ebf\u5668\u548c\u82e5\u5e72\u4e2a\u5916\u56f4\u8bbe\u5907\u53ef\u4ee5\u6784\u5efa\u4e00\u4e2aUSB\u7f51\u7edc\u3002\u672c\u7cfb\u7edf\u9009\u7528\u7684USB-hub\u7531\u4e00\u4e2aUSB\u63a5\u53e3\u6269\u5c55\u51fa4\u4e2aUSB\u63a5\u53e3\u3002<\/p>\n
\n\t2.4 USB\/\u4e32\u53e3\u8f6c\u6362\u5668\u7b80\u4ecb<\/p>\n
\n\tUSB\/\u4e32\u53e3\u8f6c\u6362\u5668\u9009\u7528\u5317\u4eac\u4e16\u7eaa\u8054\u4fe1LENSYS-USB2COM-4\u6a21\u5757\u3002\u5b83\u662f\u4e00\u79cd\u5bfc\u8f68\u5b89\u88c5\u5f0f\u4e32\u53e3\u6269\u5c55\u6a21\u5757\uff0c\u5b9e\u73b0\u4e86\u7528USB\u53e3\u6269\u5c554\u4e32\u53e3\u7684\u529f\u80fd\uff0c\u53ef\u4ee5\u901a\u8fc7USB\u5feb\u901f\u6269\u5c55\u56db\u4e2a\u8ba1\u7b97\u673a\u4e32\u53e3\uff0c\u901a\u8fc7\u62e8\u7801\u5f00\u5173\u8bbe\u5b9aRS 232\/422\/485\u63a5\u53e3\u65b9\u5f0f\uff0c\u8fd8\u53ef\u4ee5\u5b9e\u73b04\u4e2aRS 232\u8f6c4\u4e2aRS422\/485\u7684\u529f\u80fd\u3002\u901a\u8fc7\u8be5\u6a21\u5757\u80fd\u591f\u53ef\u9760\u3001\u5b9e\u65f6\u3001\u4fbf\u6377\u5730\u5b8c\u6210\u5de5\u4e1a\u73b0\u573aRS232\/485\/422\u4fe1\u53f7\u7684\u4f20\u8f93\u548c\u8f6c\u6362\uff0c\u5e7f\u6cdb\u5e94\u7528\u4e8e\u77f3\u6cb9\u5929\u7136\u6c14\u3001\u6c34\u5229\u3001\u7535\u529b\u8c03\u5ea6\u3001\u5e02\u653f\u8c03\u5ea6\u7b49\u884c\u4e1a\u3002<\/p>\n
\n\t3 \u8f6f\u4ef6\u8bbe\u8ba1<\/p>\n
\n\t\u6b64\u4e32\u53e3\u670d\u52a1\u5668\u8f6f\u4ef6\u8bbe\u8ba1\u57fa\u672c\u7ed3\u6784\u5982\u56fe2\u6240\u793a\uff0c\u5ba2\u6237\u7aef\u53ea\u662fWEB\u6d4f\u89c8\u5668\uff0c\u8f6f\u4ef6\u8bbe\u8ba1\u5219\u4e3b\u8981\u4f53\u73b0\u4e3a\u670d\u52a1\u5668\u7aef\u7684\u7f51\u9875\u5c55\u73b0\u3001\u4e1a\u52a1\u903b\u8f91\u548c\u6570\u636e\u5b58\u50a8\u3002<\/p>\n
\n\tWEB\u670d\u52a1\u5668\u8d1f\u8d23\u4e32\u53e3\u670d\u52a1\u5668\u901a\u4fe1\u53c2\u6570\u7684\u624b\u52a8\u914d\u7f6e\u548c\u5b58\u50a8\u3001\u901a\u4fe1\u7a0b\u5e8f\u7684\u624b\u52a8\u542f\u505c\u7b49;\u5e94\u7528\u670d\u52a1\u5668\u8d1f\u8d23\u5b9e\u73b0TCP\/IP\u7f51\u7edc\u4e0e\u4e32\u884c\u63a5\u53e3\u8bbe\u5907\u7684\u4e92\u901a\uff0c\u5b8c\u6210TCP\/IP\u534f\u8bae\u683c\u5f0f\u7684\u6570\u636e\u4e0e\u4e32\u884c\u6570\u636e\u95f4\u7684\u76f8\u4e92\u8f6c\u6362;\u6570\u636e\u5e93<\/u>\u4e3b\u8981\u5305\u542b\u7528\u6237\u7ba1\u7406\u6570\u636e\u8868\u3001\u4e32\u53e3\u53c2\u6570\u914d\u7f6e\u6570\u636e\u8868\u3001\u5de5\u4f5c\u6a21\u5f0f\u914d\u7f6e\u6570\u636e\u8868\u3002<\/p>\n
\n\t<\/p>\n
\n\t\u56fe2 \u8f6f\u4ef6\u8bbe\u8ba1\u57fa\u672c\u7ed3\u6784\u56fe<\/p>\n
\n\t\u4e0b\u9762\u4ecb\u7ecd\u4e32\u53e3\u670d\u52a1\u5668\u8f6f\u4ef6\u8bbe\u8ba1\u4e2d3\u4e2a\u4e3b\u8981\u4efb\u52a1\uff1aWEB\u670d\u52a1\u5668\u7684\u8bbe\u8ba1\u3001WEB\u914d\u7f6e\u9875\u9762\u7684\u8bbe\u8ba1\u548c\u4e32\u53e3\u8054\u7f51\u901a\u4fe1\u7a0b\u5e8f\u7684\u8bbe\u8ba1\u3002<\/p>\n
\n\t3.1 WEB\u670d\u52a1\u5668\u7684\u8bbe\u8ba1<\/p>\n
\n\t\u7531\u4e8e\u4e32\u53e3\u6570\u91cf\u8f83\u591a\uff0c\u6240\u4ee5\u5728\u6811\u8393\u6d3e\u4e2d\u690d\u5165WEB\u670d\u52a1\u5668\uff0c\u7531WEB\u670d\u52a1\u5668\u5c06\u7528\u6237\u7684\u8bf7\u6c42\u8f6c\u6362\u4e3a\u5bf9\u540e\u53f0\u6570\u636e\u7684\u67e5\u8be2\u6216\u66f4\u65b0\uff0c\u5e76\u5c06\u53cb\u597d\u7684\u56fe\u5f62<\/u>\u754c\u9762\u5728\u6d4f\u89c8\u5668\u4e0a\u5c55\u793a\u7ed9\u7528\u6237\uff0c\u5b9e\u73b0\u7b80\u4fbf\u7edf\u4e00\u7684\u8fdc\u7a0b\u901a\u4fe1\u53c2\u6570\u914d\u7f6e\u3001\u8bbe\u5907\u7ba1\u7406\u3001\u7528\u6237\u7ba1\u7406\u3001\u76d1\u63a7\u4e32\u53e3\u670d\u52a1\u5668\u8fd0\u884c\u72b6\u6001\u3002<\/p>\n
\n\t\u672c\u4e32\u53e3\u8054\u7f51\u670d\u52a1\u5668\u9009\u62e9\u6811\u8393\u6d3e\u81ea\u5e26\u7684Python\u4f5c\u4e3a\u5f00\u53d1\u8bed\u8a00\uff0c\u91c7\u7528\u5c0f\u5de7\u800c\u7075\u6d3b\u7684web.py\u5f00\u53d1\u6846\u67b6\u63d0\u4f9bHTTP\u670d\u52a1\uff0c\u5176\u8f7b\u91cf\u7ea7\u6ee1\u8db3\u91c7\u96c6\u7cfb\u7edf\u5bf9\u6570\u636e\u4f20\u8f93\u6a21\u5757\u7684\u8981\u6c42\uff0c\u53ef\u4ee5\u63d0\u9ad8\u7cfb\u7edf\u7684\u4f7f\u7528\u6548\u7387\uff0cWEB\u670d\u52a1\u5668\u8bbe\u8ba1\u6d41\u7a0b\u5982\u56fe3\u6240\u793a\u3002<\/p>\n
\n\t<\/p>\n
\n\t\u56fe3 WEB\u670d\u52a1\u5668\u8bbe\u8ba1\u6d41\u7a0b<\/p>\n
\n\t\u8bbe\u5907\u4e0a\u7535\u6216\u7cfb\u7edf\u91cd\u542f\u540e\uff0cWEB\u670d\u52a1\u81ea\u52a8\u542f\u52a8\uff0c\u5e76\u521d\u59cb\u5316WEB\u670d\u52a1\u5668\u6240\u9700\u663e\u793a\u548c\u914d\u7f6e\u7684\u4fe1\u606f\uff0c\u7528\u6237\u901a\u8fc7\u6d4f\u89c8\u5668\u8bbf\u95ee\u7cfb\u7edf\u6307\u5b9a\u7aef\u53e3\u8fdb\u884c\u767b\u5f55\u8ba4\u8bc1\u5373\u53ef\u8bbf\u95ee\u53c2\u6570\u914d\u7f6e\u9875\u9762\u3002\u5176\u4e2d\uff0c\u8bbe\u5907\u4fe1\u606f\u548c\u7f51\u7edc\u4fe1\u606f\u901a\u8fc7\u7cfb\u7edf\u6587\u4ef6\u7ba1\u7406\u5668\u8fdb\u884c\u67e5\u770b\u548c\u914d\u7f6e\uff0c\u7528\u6237\u4fe1\u606f\u3001\u4e32\u53e3\u53c2\u6570\u548c\u5de5\u4f5c\u6a21\u5f0f\u4fe1\u606f\u901a\u8fc7\u6570\u636e\u5e93\u8fdb\u884c\u8bfb\u5199\uff0c\u5e2e\u52a9\u4fe1\u606f\u5219\u901a\u8fc7FTP\u670d\u52a1\u5668\u8fdb\u884c\u4e32\u53e3\u670d\u52a1\u5668\u8bf4\u660e\u624b\u518c\u3001\u516c\u53f8\u670d\u52a1\u4fe1\u606f\u7b49\u6587\u6863\u4e0b\u8f7d\u3002<\/p>\n
\n\t3.2 WEB\u914d\u7f6e\u9875\u9762\u8bbe\u8ba1<\/p>\n
\n\tWEB\u914d\u7f6e\u9875\u9762\u5373WEB\u670d\u52a1\u5668\u7684\u5c55\u793a\u5c42\uff0c\u5982\u56fe4\u6240\u793a\uff0c\u626b\u63cf\u51fa\u7684\u4e32\u53e3\u6570\u8868\u660e\u8be5\u4e32\u53e3\u670d\u52a1\u5668\u5e26\u670916\u4e2a\u4e32\u53e3\uff0c\u6bcf\u4e2a\u4e32\u53e3\u914d\u7f6e\u76f8\u4e92\u72ec\u7acb\u3002<\/p>\n
\n\t<\/p>\n
\n\t\u56fe4 WEB\u914d\u7f6e\u754c\u9762<\/p>\n
\n\t\u7531\u4e8e\u914d\u7f6e\u7a0b\u5e8f\u8bbe\u8ba1\u91c7\u53d6\u5de5\u4f5c\u6a21\u5f0f\u914d\u7f6e\u4e0e\u4e32\u53e3\u53c2\u6570\u914d\u7f6e\u76f8\u5173\u8054\uff0c\u5982\u679c\u9009\u7528\u524d3\u4e2a\u4e32\u53e3\uff0c\u5219\u5de5\u4f5c\u6a21\u5f0f\u914d\u7f6e\u4e2d\u53ea\u663e\u793a\u6b643\u4e2a\u4e32\u53e3\u7684\u5de5\u4f5c\u6a21\u5f0f\u914d\u7f6e\u754c\u9762\uff0c\u5982\u56fe5\u6240\u793a\u3002<\/p>\n
\n\t<\/p>\n
\n\t\u56fe5 \u5de5\u4f5c\u6a21\u5f0f\u914d\u7f6e\u754c\u9762<\/p>\n
\n\t\u4ee5\u4e0a\u914d\u7f6e\u65b9\u5f0f\u53ef\u65b9\u4fbf\u5b9e\u73b0\u6279\u91cf\u914d\u7f6e\uff0c\u914d\u7f6e\u5b8c\u6210\u540e\u53ef\u751f\u6210\u914d\u7f6e\u4fe1\u606f\u67e5\u770b\u754c\u9762\uff0c\u5982\u56fe6\u6240\u793a\uff0c\u8be5\u754c\u9762\u8fd8\u53ef\u8fdb\u884c\u9009\u4e2d\u4e32\u53e3\u7684\u901a\u4fe1\u53c2\u6570\u3001\u5de5\u4f5c\u6a21\u5f0f\u7684\u7f16\u8f91\u548c\u5220\u9664\u3002<\/p>\n
\n\t<\/p>\n
\n\t\u56fe6 \u914d\u7f6e\u4fe1\u606f\u67e5\u770b\u754c\u9762<\/p>\n
\n\t3.3 \u4e32\u53e3\u8054\u7f51\u901a\u4fe1\u7a0b\u5e8f\u8bbe\u8ba1<\/p>\n
\n\tWEB\u670d\u52a1\u5668\u5b8c\u6210\u914d\u7f6e\u5de5\u4f5c\u540e\uff0c\u5373\u53ef\u542f\u52a8\u901a\u4fe1\u7a0b\u5e8f\u8fdb\u884c\u6570\u636e\u901a\u4fe1<\/u>\u5de5\u4f5c\uff0c\u5177\u4f53\u5b9e\u73b0\u6d41\u7a0b\u5982\u56fe7\u6240\u793a\u3002\u6b64\u7a0b\u5e8f\u5728\u8bbe\u5907\u4e0a\u7535\u6216\u7cfb\u7edf\u91cd\u542f\u540e\u81ea\u52a8\u542f\u52a8\uff0c\u8bfb\u53d6\u7528\u6237\u914d\u7f6e\u7684\u4e32\u53e3\u901a\u4fe1\u548c\u5de5\u4f5c\u6a21\u5f0f\u53c2\u6570\u540e\uff0c\u8fdb\u5165\u901a\u4fe1\u7a0b\u5e8f\u65e0\u9650\u5faa\u73af\uff0c\u56fe\u4e2d\u8fdb\u7a0b\u6570\u5373\u73b0\u573a\u5e94\u7528\u6240\u914d\u7f6e\u7684\u4e32\u53e3\u603b\u6570\u3002\u5176\u4e2dN\u4e3a\u4e32\u53e3\u670d\u52a1\u5668\u4e32\u53e3\u6570\uff0cM(M≤W)\u4e3aN\u4e2a\u4e32\u53e3\u4e2d\u4f7f\u7528\u7684\u4e32\u53e3\u6570;n\u4e3a\u5404\u81ea\u7f16\u53f7\uff0cI\u4e3a\u8fdb\u7a0b\u7f16\u53f7;S\u4e3a\u6240\u914d\u4f1a\u8bdd\u6570\uff0cs\u4e3a\u7ebf\u7a0b\u7f16\u53f7\u3002<\/p>\n
\n\t<\/p>\n
\n\t\u56fe7 \u4e32\u53e3\u670d\u52a1\u5668\u901a\u4fe1\u7a0b\u5e8f\u5de5\u4f5c\u6d41\u7a0b<\/p>\n
\n\t3\u79cd\u5de5\u4f5c\u6a21\u5f0f\u4e2d\uff0cTCP\u670d\u52a1\u5668\u548cTCP\u5ba2\u6237\u7aef\u540c\u5c5eTCP\u534f\u8bae\u4f20\u8f93\u7a0b\u5e8f\uff0c\u5176\u6570\u636e\u5e27\u6536\u53d1\u5904\u7406\u8fc7\u7a0b\u90fd\u91c7\u7528\u540c\u4e00\u79cd\u601d\u60f3\uff0c\u4e0b\u9762\u4ecb\u7ecdTCP\u3001UDP\u534f\u8bae\u4f20\u8f93\u7a0b\u5e8f\u548c\u6570\u636e\u5e27\u8f6c\u53d1\u7a0b\u5e8f\u7684\u8bbe\u8ba1\uff1a<\/p>\n
\n\t3.3.1 TOP\u534f\u8bae\u4f20\u8f93\u7a0b\u5e8f\u8bbe\u8ba1<\/p>\n
\n\tTCP\u534f\u8bae\u4f20\u8f93\u7a0b\u5e8f\u6d89\u53ca\u5230\u670d\u52a1\u5668\u7aef\u548c\u5ba2\u6237\u7aef\u7684\u8bbe\u8ba1\u3002<\/p>\n
\n\t\u670d\u52a1\u5668\u7aef\u7a0b\u5e8f\u8bbe\u8ba1\uff1a<\/p>\n
\n\t\u2460\u5efa\u7acb\u4e00\u4e2asocket\uff0c\u9009\u62e9\u7c7b\u578bINET\u53caTCP\u8fde\u63a5\u65b9\u5f0f;<\/p>\n
\n\t\u2461\u8bfb\u53d6\u914d\u7f6e\u7aef\u53e3\u8fdb\u884c\u7ed1\u5b9a\u76d1\u542c\uff0c\u7b49\u5f85\u5ba2\u6237\u7aef\u4e3b\u52a8\u8fde\u63a5;<\/p>\n
\n\t\u2462\u8bbe\u7f6e\u76d1\u542c\u961f\u5217\u5927\u5c0f;<\/p>\n
\n\t\u2463\u8fdb\u5165\u4e00\u4e2a\u65e0\u9650\u5faa\u73af\uff0c\u4f7f\u7528accept()\u7b49\u5f85\u5ba2\u6237\u8fde\u63a5\uff0c\u8fd4\u56de\u7684\u65b0\u8fde\u63a5\u5bf9\u5e94\u4e8e\u5ba2\u6237\u7aefIP\uff0c\u5efa\u7acb\u901a\u4fe1\u4fe1\u9053;<\/p>\n
\n\t\u2464\u8fdb\u5165\u65e0\u9650\u5b50\u5faa\u73af\uff0c\u901a\u8fc7sendall()\u53carecv()\u8fdb\u884c\u8bfb\u5199\u64cd\u4f5c\u3002<\/p>\n
\n\t\u5ba2\u6237\u7aef\u7a0b\u5e8f\u8bbe\u8ba1\uff1a<\/p>\n
\n\t\u2460\u5efa\u7acb\u4e00\u4e2asocket\uff0c\u9009\u62e9\u7c7b\u578b\u53ca\u8fde\u63a5\u65b9\u5f0f\u540c\u670d\u52a1\u5668\u7aef;<\/p>\n
\n\t\u2461\u8bfb\u53d6\u914d\u7f6e\u6240\u914d\u7f6e\u8fdc\u7a0b\u670d\u52a1\u5668IP\u53ca\u7aef\u53e3;<\/p>\n
\n\t\u2462\u8fdb\u5165\u65e0\u9650\u5faa\u73af\uff0c\u4f7f\u7528connect()\u8fde\u63a5\u8fdc\u7a0b\u670d\u52a1\u5668\uff0c\u82e5\u8fde\u4e0d\u4e0a\uff0c\u8fbe\u5230\u6240\u914d\u7f6e\u8d85\u65f6\u95f4\u9694\u540e\u518d\u6b21\u91cd\u8fde;<\/p>\n
\n\t\u2463\u8fde\u63a5\u6210\u529f\u540e\u8fdb\u5165\u65e0\u9650\u5b50\u5faa\u73af\uff0c\u901a\u8fc7sendall()\u53carecv()\u8fdb\u884c\u8bfb\u5199\u64cd\u4f5c\u3002<\/p>\n
\n\t3.3.2 UDP\u534f\u8bae\u4f20\u8f93\u7a0b\u5e8f\u8bbe\u8ba1<\/p>\n
\n\tUDP\u4f20\u8f93\u79f0\u4e3a\u65e0\u8fde\u63a5\u4f20\u8f93\uff0c\u4e0d\u5b58\u5728TCP\u4e2d\u7684\u4e09\u6b21\u63e1\u624b\u548c\u9519\u8bef\u91cd\u4f20\u673a\u5236\uff0c\u5176\u4f20\u8f93\u7a0b\u5e8f\u9700\u540c\u65f6\u8bfb\u53d6\u6240\u914d\u7f6e\u7684\u672c\u5730IP\u548c\u7aef\u53e3\u3001\u8fdc\u7a0bIP\u548c\u7aef\u53e3\uff0c\u5efa\u7acb\u6570\u636e\u62a5\u5f62\u5f0f\u7684socket\u540e\u53ef\u540c\u65f6\u4f5c\u4e3a\u53d1\u9001\u7aef\u548c\u63a5\u6536\u7aef\u3002\u4f5c\u4e3a\u53d1\u9001\u7aef\u65f6\uff0csendto()\u53d1\u9001\u5730\u5740\u4e3a\u8fdc\u7a0b\u63a5\u6536\u7aefIP\u548c\u7aef\u53e3\uff0c\u4f5c\u4e3a\u63a5\u6536\u7aef\u65f6\u516c\u5f00\u672c\u5730IP\u548c\u7aef\u53e3\uff0crecvfrom<\/u>()\u7b49\u5f85\u8fdc\u7a0b\u53d1\u9001\u7aef\u7684\u6570\u636e\u5230\u6765\uff0c\u53ef\u4ee5\u63a5\u6536\u4efb\u4f55\u5730\u5740\u53d1\u9001\u8fc7\u6765\u7684\u6570\u636e\u5305\u3002<\/p>\n
\n\t3.3.3 \u6570\u636e\u5e27\u8f6c\u53d1\u7a0b\u5e8f\u8bbe\u8ba1<\/p>\n
\n\t\u4e32\u53e3\u670d\u52a1\u5668\u529f\u80fd\u6a21\u5757\u5b9e\u73b0\u4e86\u4e32\u884c\u94fe\u8def\u6570\u636e\u4e0e\u4ee5\u592a\u7f51\u6570\u636e\u8f6c\u6362\u7684\u529f\u80fd\uff1a\u4e00\u65b9\u9762\uff0c\u63a5\u6536\u6765\u81ea\u4e32\u884c\u94fe\u8def\u7684\u6570\u636e\u5e27\uff0c\u5e76\u5c06\u5176\u8f6c\u5316\u4e3a\u4ee5\u592a\u7f51\u94fe\u8def\u6570\u636e\u5e27\u540e\u53d1\u51fa;\u53e6\u4e00\u65b9\u9762\uff0c\u63a5\u6536\u6765\u81ea\u4ee5\u592a\u7f51\u94fe\u8def\u7684\u6570\u636e\u5e27\uff0c\u5e76\u5c06\u5176\u8f6c\u5316\u4e3a\u4e32\u884c\u94fe\u8def\u6570\u636e\u5e27\u540e\u53d1\u51fa\u3002\u4ee5\u4e0a\u4e24\u4e2a\u901a\u4fe1\u8fc7\u7a0b\u5e76\u884c\u6267\u884c\uff0c\u5728\u7a0b\u5e8f\u8bbe\u8ba1\u4e2d\u91c7\u53d6\u591a\u7ebf\u7a0b\u5b9e\u73b0\u65b9\u5f0f\u3002<\/p>\n
\n\t(1)\u7f51\u7edc\u6570\u636e\u7684\u63a5\u6536<\/p>\n
\n\t\u6bcf\u79cd\u901a\u4fe1\u6a21\u5f0f\u4e0b\uff0c\u7f51\u7edc\u6570\u636e\u7684\u63a5\u6536\u90fd\u5728\u6307\u5b9a\u7684\u56de\u8c03\u51fd\u6570\u4e2d\u5b9e\u73b0\uff0cTCP\u901a\u4fe1\u63a5\u6536\u51fd\u6570\u4e3arecv()\uff0c\u800cUDP\u901a\u4fe1\u4e2d\u4e3arecvfrom()\u3002\u5f53\u6570\u636e\u5e27\u957f\u5ea6\u79ef\u7d2f\u5230\u6307\u5b9a\u7684\u63a5\u6536\u7f13\u51b2\u533a\u5927\u5c0f\u6216\u8fbe\u5230\u4e32\u53e3\u8d85\u65f6\u8fd8\u4e0d\u8db3\u6307\u5b9a\u6570\u636e\u5e27\u957f\u5ea6\uff0c\u7acb\u5373\u8c03\u7528\u5b9e\u4f8b\u5316\u540e\u7684\u4e32\u53e3\u53d1\u9001\u51fd\u6570write<\/u>()\uff0c\u5373\u53ef\u5c06\u7f13\u51b2\u533a\u4e2d\u63a5\u6536\u5230\u7684\u6570\u636e\u901a\u8fc7\u4e32\u53e3\u8f6c\u53d1\u3002<\/p>\n
\n\t(2)\u7f51\u7edc\u6570\u636e\u7684\u53d1\u9001<\/p>\n
\n\t\u63a5\u6536\u4e32\u53e3\u6570\u636e\u65f6\u8c03\u7528\u4e32\u53e3\u63a5\u6536\u51fd\u6570read()\uff0c\u5f53\u6570\u636e\u5e27\u957f\u5ea6\u8fbe\u5230\u4e32\u53e3\u63a5\u6536\u7f13\u51b2\u533a\u5927\u5c0f\u6216\u4e32\u53e3\u8d85\u65f6\uff0c\u7acb\u5373\u8c03\u7528\u7f51\u7edc\u53d1\u9001\u51fd\u6570\u628a\u8be5\u7f13\u51b2\u533a\u4e2d\u7684\u6570\u636e\u5e27\u901a\u8fc7\u7f51\u53e3\u8f6c\u53d1\uff0c\u5176\u4e2dTCP\u901a\u4fe1\u53d1\u9001\u51fd\u6570\u4e3asendall()\uff0c\u800cUDP\u901a\u4fe1\u4e3asendto()\u3002<\/p>\n
\n\t\u7ed3\u8bed<\/p>\n
\n\t\u7ecf\u5168\u9762\u6d4b\u8bd5<\/u>\u5408\u683c\u540e\uff0c\u76ee\u524d\u672c\u4e32\u53e3\u670d\u52a1\u5668\u5df2\u7ecf\u6210\u529f\u5e94\u7528\u5230\u5de5\u4e1a\u73b0\u573a\uff0c\u7531\u6b64\u53ef\u89c1\uff0c\u672c\u4e32\u53e3\u670d\u52a1\u5668\u652f\u6301\u9ad8\u9891\u8f6c\u53d1\u3001\u5927\u6570\u636e<\/u>\u5e27\u5b9e\u65f6\u8f6c\u53d1\uff0c\u53ef\u957f\u671f\u3001\u5168\u5929\u5019\u7a33\u5b9a\u8fd0\u884c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"
\u5de5\u4e1a\u63a7\u5236\u4e2d\uff0c\u5404\u8bbe\u5907\u7684\u4fe1\u53f7\u91c7\u96c6\u548c\u76d1\u63a7\u53ea\u9760\u4e32\u53e3\u603b\u7ebf\u96be\u4ee5\u5b9e\u73b0\u6269\u5c55\uff0c\u8981\u5c06\u73b0\u573a\u63a7\u5236\u7f51\u7edc\u548c\u4fe1\u606f\u7f51\u7edc\u76f8\u8fde\uff0c\u5c31\u9700\u8981\u89e3\u51b3\u4e32\u53e3\u901a\u4fe1\u534f\u8bae\u548c\u56e0\u7279\u7f51\u901a\u4fe1\u534f\u8bae\u7684\u8f6c\u6362\u95ee\u9898\uff0c\u5373\u628a\u539f\u6709\u8bbe\u5907\u8f6c\u6362\u4e3a\u5177<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14],"tags":[],"_links":{"self":[{"href":"http:\/\/www.szryc.com\/index.php?rest_route=\/wp\/v2\/posts\/2502"}],"collection":[{"href":"http:\/\/www.szryc.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.szryc.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.szryc.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.szryc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2502"}],"version-history":[{"count":0,"href":"http:\/\/www.szryc.com\/index.php?rest_route=\/wp\/v2\/posts\/2502\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.szryc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2502"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.szryc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2502"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.szryc.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2502"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}