{"id":213668,"date":"2021-03-25T09:57:07","date_gmt":"2021-03-25T01:57:07","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=213668"},"modified":"2021-03-16T08:58:10","modified_gmt":"2021-03-16T00:58:10","slug":"socket-programming","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/socket-programming.html","title":{"rendered":"\u5957\u63a5\u5b57\u7f16\u7a0b\u521d\u5b66\u8005\u6307\u5357"},"content":{"rendered":"
\u5bfc\u8bfb<\/td>\n | \u5957\u63a5\u5b57\u662f\u7f51\u7edc\u95f4\u901a\u4fe1\u7684\u7aef\u70b9\uff0c\u5957\u63a5\u5b57\u7f16\u7a0b\u4f7f\u8fd9\u4e9b\u7aef\u70b9\u80fd\u591f\u4f20\u8f93\u6570\u636e\uff0c\u4ece\u800c\u652f\u6301\u7f51\u7edc\u548c\u7a0b\u5e8f\u4e4b\u95f4\u7684\u901a\u4fe1\u3002\u5bf9\u4e8e\u521d\u5b66\u8005\u6765\u8bf4\uff0c\u5957\u63a5\u5b57\u7f16\u7a0b\u5f88\u91cd\u8981\uff0c\u53ef\u4ee5\u7406\u89e3\u7f51\u7edc\u5982\u4f55\u901a\u4fe1\u3002 \n<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n <\/p>\n \u5957\u63a5\u5b57\u662f\u7f51\u7edc\u95f4\u901a\u4fe1\u7684\u7aef\u70b9\uff0c\u5957\u63a5\u5b57\u7f16\u7a0b\u4f7f\u8fd9\u4e9b\u7aef\u70b9\u80fd\u591f\u4f20\u8f93\u6570\u636e\uff0c\u4ece\u800c\u652f\u6301\u7f51\u7edc\u548c\u7a0b\u5e8f\u4e4b\u95f4\u7684\u901a\u4fe1\u3002\u5bf9\u4e8e\u521d\u5b66\u8005\u6765\u8bf4\uff0c\u5957\u63a5\u5b57\u7f16\u7a0b\u5f88\u91cd\u8981\uff0c\u53ef\u4ee5\u7406\u89e3\u7f51\u7edc\u5982\u4f55\u901a\u4fe1\u3002<\/p>\n \u5957\u63a5\u5b57\u7f16\u7a0b\u5177\u6709\u5f88\u591a\u597d\u5904\uff0c\u4f8b\u5982\u5e2e\u52a9\u5b9e\u65f6\u8fde\u63a5\uff0c\u5e76\u4e14\u53ef\u4ee5\u4f7f\u7528\u591a\u79cd\u7f16\u7a0b\u8bed\u8a00\u3002\u6700\u53d7\u6b22\u8fce\u7684\u7f16\u7a0b\u8bed\u8a00\u9009\u9879\u4e4b\u4e00\u662fPython\uff0c\u5b83\u662f\u7f51\u7edc\u4e13\u4e1a\u4eba\u5458\u5728\u804c\u4e1a\u751f\u6daf\u4e2d\u4f1a\u7528\u5230\u7684\u901a\u7528\u8bed\u8a00\u3002\u300a\u638c\u63e1Python\u7684\u7f51\u7edc\u548c\u5b89\u5168\u300b\u4e00\u4e66\u7684\u4f5c\u8005Jos\u00e9Manuel Ortega\u8ba4\u4e3a\uff0c\u867d\u7136Python\u4e0d\u662f\u5957\u63a5\u5b57\u7f16\u7a0b\u521d\u5b66\u8005\u5e94\u8be5\u5b66\u4e60\u7684\u552f\u4e00\u8bed\u8a00\uff0c\u4f46\u5b83\u5177\u6709\u5404\u79cd\u5de5\u5177\u548c\u6a21\u5757\u6765\u5e2e\u52a9\u5904\u7406\u6570\u636e\u5305\uff0c\u5e76\u63d0\u4f9b\u9ad8\u5c42\u6b21\u548c\u4f4e\u5c42\u6b21\u65b9\u6cd5\u6765\u5904\u7406\u5957\u63a5\u5b57\u3002<\/p>\n \u300a\u638c\u63e1Python\u7684\u7f51\u7edc\u548c\u5b89\u5168\u300b\u7b2c\u4e8c\u7248\u63a2\u8ba8\u4e86Python\u5e93\u548c\u811a\u672c\u7684\u7f51\u7edc\u548c\u5b89\u5168\uff0c\u5e76\u63a2\u7d22\u4e86HTTP\u548c\u5957\u63a5\u5b57\u7f16\u7a0b\u7b49\u65b9\u9762\u6765\u5e2e\u52a9\u521d\u5b66\u8005\u5b66\u4e60\u3002<\/p>\n \u521d\u5b66\u8005\u5bf9\u5957\u63a5\u5b57\u7f16\u7a0b\u7684\u5e38\u89c1\u95ee\u9898\u6709\u54ea\u4e9b?<\/strong><\/div>\n Jos\u00e9 Manuel Ortega\uff1a\u5bf9\u4e8e\u521d\u5b66\u8005\u6765\u8bf4\uff0c\u6700\u5e38\u89c1\u7684\u95ee\u9898\u4e0e\u5957\u63a5\u5b57\u7684\u5b9e\u7528\u7a0b\u5e8f\u6709\u5173\uff0c\u5728\u9ad8\u5c42\u6b21\u6765\u770b\uff0c\u6211\u4eec\u5728\u7f16\u7a0b\u8bed\u8a00(\u4f8b\u5982Python\u548cC \/ C ++)\u4e2d\u53ef\u4f7f\u7528\u54ea\u4e9b\u5e93\uff0c\u800c\u5728\u8f83\u4f4e\u5c42\u6b21\u4e0a\uff0c\u5219\u6d89\u53ca\u64cd\u4f5c\u7cfb\u7edf\u5982\u4f55\u4f7f\u7528\u5b83\u7528\u4e8e\u5e94\u7528\u7a0b\u5e8f\u95f4\u7684\u901a\u4fe1\u3002<\/p>\n \u6700\u540e\uff0c\u6211\u8ba4\u4e3a\u8fd9\u5e76\u4e0d\u4f1a\u5728\u5f88\u5927\u7a0b\u5ea6\u4e0a\u53d6\u51b3\u6240\u4f7f\u7528\u7684\u5e93\uff0c\u5177\u4f53\u53d6\u51b3\u4e8e\u5b83\u4eec\u7684\u7f16\u7a0b\u8bed\u8a00\u6216\u64cd\u4f5c\u7cfb\u7edf\u3002\u6700\u7ec8\uff0c\u8fd9\u66f4\u591a\u5730\u53d6\u51b3\u4e8e\u4eba\u4eec\u5bf9\u4e8e\u7f51\u7edc\u548c\u5b89\u5168\u6982\u5ff5\u7684\u7406\u89e3\uff0c\u4ee5\u53ca\u5982\u4f55\u5728\u65e0\u9700\u4e86\u89e3\u5e93\u6216\u7279\u5b9a\u8bed\u8a00\u7684\u60c5\u51b5\u4e0b\u89e3\u51b3\u7279\u5b9a\u95ee\u9898\u3002<\/p>\n \u5e93\u548cPython\u8fd9\u6837\u7684\u8bed\u8a00\uff0c\u53ef\u4ee5\u5e2e\u52a9\u4f60\u627e\u5230\u89e3\u51b3\u65b9\u6848\uff0c\u4f46\u5b83\u4eec\u672c\u8eab\u5e76\u4e0d\u80fd\u4e3a\u4f60\u63d0\u4f9b\u89e3\u51b3\u65b9\u6848\uff0c\u56e0\u4e3a\u4f60\u9700\u8981\u4e86\u89e3\u7f51\u7edc\u4ee5\u53ca\u534f\u8bae\u548c\u64cd\u4f5c\u7cfb\u7edf\u7684\u57fa\u672c\u5de5\u4f5c\u539f\u7406\u3002\u7136\u540e\u518d\u5b66\u4e60\u67d0\u79cd\u5e93\u6216\u7f16\u7a0b\u8bed\u8a00\uff0c\u8fd9\u5e76\u4e0d\u662f\u6700\u91cd\u8981\u7684\u4e8b\u60c5\u3002<\/p>\n \u5982\u679c\u6709\u4eba\u66f4\u5177\u4f53\u5730\u8be2\u95ee\u6211\u6709\u5173Python\u4e2d\u4f7f\u7528\u7684\u5e93\u7684\u4fe1\u606f\uff0c\u6211\u5c06\u63a8\u8350\u6211\u5728\u4e66\u4e2d\u5206\u6790\u7684\u90a3\u4e9b\u5e93\u3002\u6839\u636e\u4f60\u6700\u559c\u6b22\u7684\u8bed\u8a00\uff0c\u4f60\u4f1a\u6709\u4e0d\u540c\u7684\u9009\u62e9\uff0c\u6211\u5efa\u8bae\u4f60\u5c1d\u8bd5\u4f7f\u7528\u5176\u4ed6\u5177\u6709\u66f4\u597d\u6027\u80fd\u7684\u8bed\u8a00\uff0c\u4f8b\u5982C \/ C ++\u3002<\/p>\n \u5957\u63a5\u5b57\u7f16\u7a0b\u5bf9\u7f51\u7edc\u548c\u5b89\u5168\u7684\u597d\u5904\u548c\u6311\u6218\u662f\u4ec0\u4e48?<\/strong><\/div>\n Ortega\uff1a\u4ece\u7f51\u7edc\u7684\u89d2\u5ea6\u6765\u770b\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u5957\u63a5\u5b57\u6765\u90e8\u7f72\u5ba2\u6237\u7aef\u670d\u52a1\u5668\u5e94\u7528\u7a0b\u5e8f-\u4f8b\u5982\uff0c\u804a\u5929\u5e94\u7528\u7a0b\u5e8f\u3002\u4ece\u5b89\u5168\u7684\u89d2\u5ea6\u6765\u770b\uff0c\u5957\u63a5\u5b57\u5728\u8f83\u4f4e\u7ea7\u522b\u4e0a\u7528\u4e8e\u786e\u5b9a\u8ba1\u7b97\u673a\u5df2\u6253\u5f00\u7684\u7aef\u53e3\uff0c\u800c\u5178\u578b\u7684\u7aef\u53e3\u626b\u63cf\u7a0b\u5e8f\u5de5\u5177(\u4f8b\u5982Nmap)\u5728\u8f83\u4f4e\u7ea7\u522b\u4e0a\u4f7f\u7528\u5b83\u4eec\u3002\u5b83\u4eec\u4e5f\u53ef\u4ee5\u7528\u4e8e\u8fde\u63a5\u5230\u5916\u90e8\u670d\u52a1\u5668-\u901a\u8fc7\u4f7f\u7528\u53cd\u5411Shell\uff0c\u8fd9\u4e0e\u6211\u4eec\u4f7f\u7528SSH [Secure Socket Shell]\u547d\u4ee4\u7684\u65b9\u5f0f\u76f8\u540c\u3002<\/p>\n \u4e3b\u8981\u6311\u6218\u5728\u4e8e\uff0c\u80fd\u5426\u5f02\u6b65\u53d1\u51fa\u8bf7\u6c42\uff0c\u4f8b\u5982\uff0c\u901a\u8fc7python-socketio\u9879\u76ee\uff0c\u4f60\u53ef\u4ee5\u90e8\u7f72\u5ba2\u6237\u7aef\u3001\u5e94\u7528\u7a0b\u5e8f\u548c\u670d\u52a1\u5668\uff0c\u53ef\u4e0ePython Web\u6846\u67b6(\u4f8b\u5982Flask)\u96c6\u6210\u3002<\/p>\n \u5bf9\u4e8e\u4f20\u8f93\u63a7\u5236\u534f\u8bae(TCP)\u5230\u7528\u6237\u6570\u636e\u62a5\u534f\u8bae(UDP)\uff0c\u5957\u63a5\u5b57\u7f16\u7a0b\u6709\u4ec0\u4e48\u4e0d\u540c?<\/strong><\/div>\n Ortega\uff1aTCP\u548cUDP\u4e4b\u95f4\u7684\u4e3b\u8981\u533a\u522b\u5728\u4e8eTCP\u662f\u9762\u5411\u8fde\u63a5\u7684\u3002\u8fd9\u610f\u5473\u7740\u5b83\u53ef\u4ee5\u4fdd\u8bc1\u6211\u4eec\u7684\u6570\u636e\u5305\u5c06\u5230\u8fbe\u76ee\u7684\u5730\uff0c\u5e76\u5728\u6570\u636e\u5305\u4f20\u9012\u5931\u8d25\u65f6\u53d1\u51fa\u9519\u8bef\u901a\u77e5\u3002\u53e6\u4e00\u65b9\u9762\uff0cUDP\u5219\u9002\u7528\u4e8e\u9700\u8981\u9ad8\u6548\u901a\u4fe1\u4e14\u4e0d\u5fc5\u62c5\u5fc3\u6570\u636e\u5305\u4e22\u5931\u7684\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n \u5728Python\u4e2d\u4f7f\u7528TCP\u548cUDP\u7684\u4e3b\u8981\u533a\u522b\u5728\u4e8e\uff0c\u521b\u5efa\u5957\u63a5\u5b57\u65f6\uff0c\u5fc5\u987b\u5c06SOCK_DGRAM\u7528\u4e8eUDP\uff0c\u5c06SOCK_STREAM\u7528\u4e8eTCP\u3002<\/p>\n \u4e3a\u4ec0\u4e48\u7f51\u7edc\u4e13\u4e1a\u4eba\u5458\u5e94\u8be5\u4f7f\u7528Python\u8fdb\u884c\u5957\u63a5\u5b57\u7f16\u7a0b\u800c\u4e0d\u662f\u53e6\u4e00\u79cd\u8bed\u8a00?<\/strong><\/div>\n Ortega\uff1aPython\u63d0\u4f9b\u6240\u9700\u7684\u5957\u63a5\u5b57\u6a21\u5757\uff0c\u4ee5\u5728\u9ad8\u7ea7\u522b\u548c\u4f4e\u7ea7\u522b\u4f7f\u7528\u5957\u63a5\u5b57\u3002\u5957\u63a5\u5b57\u6a21\u5757\u63d0\u4f9b\u6240\u6709\u5fc5\u9700\u7684\u529f\u80fd\uff0c\u53ef\u4ee5\u5feb\u901f\u7f16\u5199TCP\u548cUDP\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u5668\u3002<\/p>\n Python\u8fd8\u63d0\u4f9b\u5176\u4ed6\u5de5\u5177\uff0c\u7528\u4e8e\u5904\u7406\u7f51\u7edc\u6570\u636e\u5305\uff0c\u4f8b\u5982Scapy\uff0c\u5b83\u662f\u7528Python\u7f16\u5199\u7684\u6a21\u5757\uff0c\u7528\u4e8e\u5904\u7406\u652f\u6301\u591a\u79cd\u7f51\u7edc\u534f\u8bae\u7684\u6570\u636e\u5305\u3002\u8be5\u5de5\u5177\u5141\u8bb8\u521b\u5efa\u548c\u4fee\u6539\u5404\u79cd\u7c7b\u578b\u7684\u7f51\u7edc\u6570\u636e\u5305\uff0c\u5b9e\u73b0\u6355\u83b7\u548c\u55c5\u63a2\u6570\u636e\u5305\u7684\u529f\u80fd\u3002<\/p>\n \u6b64\u5916\uff0c\u5982\u679c\u6211\u4eec\u5c06\u5176\u4e0eC \/ C ++\u4e4b\u7c7b\u7684\u7a0b\u5e8f\u8fdb\u884c\u6bd4\u8f83\uff0c\u5176\u5b66\u4e60\u66f2\u7ebf\u4e5f\u5f88\u4f4e\u3002<\/p>\n \u4ec0\u4e48\u5728\u63a8\u52a8\u5957\u63a5\u5b57\u7f16\u7a0b\u7684\u90e8\u7f72?\u6709\u6ca1\u6709\u53ef\u884c\u7684\u66ff\u4ee3\u65b9\u6848?<\/strong><\/div>\n Ortega\uff1a\u5957\u63a5\u5b57\u63d0\u4f9b\u7684\u4e3b\u8981\u4f18\u70b9\u662f\u5b83\u4eec\u5177\u6709\u5b9e\u65f6\u7ef4\u62a4\u8fde\u63a5\u7684\u80fd\u529b\uff0c\u5e76\u4e14\u6211\u4eec\u53ef\u4ee5\u5728\u8fde\u63a5\u7684\u4e00\u7aef\u5230\u53e6\u4e00\u7aef\u4e4b\u95f4\u53d1\u9001\u548c\u63a5\u6536\u6570\u636e\u3002\u4f8b\u5982\uff0c\u6211\u4eec\u53ef\u4ee5\u521b\u5efa\u81ea\u5df1\u7684\u5ba2\u6237\u7aef-\u670d\u52a1\u5668\u5e94\u7528\u7a0b\u5e8f\uff0c\u8be5\u5e94\u7528\u7a0b\u5e8f\u5141\u8bb8\u6211\u4eec\u5b9e\u65f6\u63a5\u6536\u548c\u53d1\u9001\u6d88\u606f\uff0c\u5e76\u4ee5\u5f02\u6b65\u65b9\u5f0f\u5904\u7406\u8fd9\u4e9b\u6d88\u606f\u3002<\/p>\n \u5728Python\u4e2d\u4f7f\u7528\u5957\u63a5\u5b57\u7684\u4e3b\u8981\u66ff\u4ee3\u65b9\u6cd5\u662f\uff0c\u6211\u4eec\u53ef\u4ee5\u5728asyncio\u6a21\u5757\u4e2d\u627e\u5230\u8be5\u6a21\u5757\uff0c\u8be5\u6a21\u5757\u5141\u8bb8\u6211\u4eec\u5e76\u884c\u6267\u884c\u5f02\u6b65\u8c03\u7528\uff0c\u4ee5\u5e76\u884c\u542f\u52a8\u8bf7\u6c42\u3002<\/p>\n","protected":false},"excerpt":{"rendered":" \u5957\u63a5\u5b57\u662f\u7f51\u7edc\u95f4\u901a\u4fe1\u7684\u7aef\u70b9\uff0c\u5957\u63a5\u5b57\u7f16\u7a0b\u4f7f\u8fd9\u4e9b\u7aef\u70b9\u80fd\u591f\u4f20\u8f93\u6570\u636e\uff0c\u4ece\u800c\u652f\u6301\u7f51\u7edc\u548c\u7a0b\u5e8f\u4e4b\u95f4\u7684\u901a\u4fe1\u3002\u5bf9\u4e8e\u521d\u5b66\u8005\u6765\u8bf4\uff0c\u5957\u63a5 […]<\/p>\n","protected":false},"author":317,"featured_media":211288,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-213668","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\/213668","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\/317"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=213668"}],"version-history":[{"count":1,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/213668\/revisions"}],"predecessor-version":[{"id":213670,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/213668\/revisions\/213670"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/211288"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=213668"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=213668"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=213668"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}} |