{"id":54216,"date":"2025-08-12T23:59:54","date_gmt":"2025-08-12T15:59:54","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/54216.html"},"modified":"2025-08-12T23:59:54","modified_gmt":"2025-08-12T15:59:54","slug":"%e6%b7%b1%e5%85%a5%e7%90%86%e8%a7%a3%e5%ae%a2%e6%88%b7%e7%ab%af-%e6%9c%8d%e5%8a%a1%e5%99%a8%e7%bd%91%e7%bb%9c%e9%80%9a%e4%bf%a1%e6%9e%b6%e6%9e%84","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/54216.html","title":{"rendered":"\u6df1\u5165\u7406\u89e3\u5ba2\u6237\u7aef-\u670d\u52a1\u5668\u7f51\u7edc\u901a\u4fe1\u67b6\u6784"},"content":{"rendered":"<p>  \u672c\u6587\u8fd8\u6709\u914d\u5957\u7684\u7cbe\u54c1\u8d44\u6e90&#xff0c;\u70b9\u51fb\u83b7\u53d6  <img decoding=\"async\" alt=\"menu-r.4af5f7ec.gif\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250812155953-689b64f92202d.gif\" style=\"width:16px;margin-left:4px;vertical-align:text-bottom;cursor:text\" \/> <\/p>\n<p> \u7b80\u4ecb&#xff1a;\u5728IT\u9886\u57df&#xff0c;\u5ba2\u6237\u7aef-\u670d\u52a1\u5668&#xff08;Client-Sever&#xff09;\u67b6\u6784\u662f\u5e38\u89c1\u7684\u7f51\u7edc\u901a\u4fe1\u6a21\u5f0f&#xff0c;\u7528\u4e8e\u5904\u7406\u5e94\u7528\u7a0b\u5e8f\u5982\u767b\u5f55\u3001\u6ce8\u518c\u3001\u804a\u5929\u7cfb\u7edf\u7b49\u3002\u5ba2\u6237\u7aef\u8fd0\u884c\u5728\u7528\u6237\u8bbe\u5907\u4e0a&#xff0c;\u670d\u52a1\u5668\u8fd0\u884c\u5728\u8fdc\u7a0b\u4e3b\u673a\u4e0a\u5904\u7406\u6570\u636e\u548c\u670d\u52a1\u8bf7\u6c42\u3002\u670d\u52a1\u5668\u901a\u5e38\u901a\u8fc7Socket\u63a5\u53e3\u4e0e\u5ba2\u6237\u7aef\u901a\u4fe1&#xff0c;\u4f7f\u7528TCP\/IP\u6216UDP\u534f\u8bae\u3002\u5728\u5b9e\u73b0\u767b\u5f55\u3001\u6ce8\u518c\u548c\u804a\u5929\u65f6&#xff0c;\u670d\u52a1\u5668\u7aef\u4f1a\u8fdb\u884c\u8eab\u4efd\u9a8c\u8bc1\u3001\u6570\u636e\u5e93\u64cd\u4f5c&#xff0c;\u5e76\u786e\u4fdd\u901a\u4fe1\u5b89\u5168\u3002\u540c\u65f6&#xff0c;\u8fd8\u9700\u8981\u8003\u8651\u6027\u80fd\u3001\u9519\u8bef\u5904\u7406\u548c\u5e76\u53d1\u63a7\u5236&#xff0c;\u4ee5\u4f18\u5316\u7528\u6237\u4f53\u9a8c\u3002  <img decoding=\"async\" alt=\"Client-Sever Access\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250812155953-689b64f945441.png\" \/> <\/p>\n<h2> 1. \u5ba2\u6237\u7aef-\u670d\u52a1\u5668\u67b6\u6784\u6a21\u5f0f\u6982\u5ff5 <\/h2>\n<h3> 1.1 \u57fa\u7840\u5b9a\u4e49\u4e0e\u91cd\u8981\u6027 <\/h3>\n<p> \u5ba2\u6237\u7aef-\u670d\u52a1\u5668&#xff08;Client-Server&#xff09;\u67b6\u6784\u662f\u4e00\u79cd\u5206\u5e03\u5f0f\u8ba1\u7b97\u6a21\u578b&#xff0c;\u5176\u6838\u5fc3\u5728\u4e8e\u5c06\u4efb\u52a1\u5206\u4e3a\u4e24\u90e8\u5206&#xff0c;\u4e00\u90e8\u5206\u7531\u5ba2\u6237\u7aef\u5b8c\u6210&#xff0c;\u53e6\u4e00\u90e8\u5206\u7531\u670d\u52a1\u5668\u7aef\u5904\u7406\u3002\u8fd9\u79cd\u6a21\u5f0f\u7684\u7279\u70b9\u662f\u9ad8\u5ea6\u6a21\u5757\u5316&#xff0c;\u6613\u4e8e\u6269\u5c55\u548c\u7ef4\u62a4\u3002 <\/p>\n<h3> 1.2 \u67b6\u6784\u6a21\u5f0f\u7684\u5de5\u4f5c\u6d41\u7a0b <\/h3>\n<p> \u5728\u5ba2\u6237\u7aef-\u670d\u52a1\u5668\u67b6\u6784\u4e2d&#xff0c;\u5ba2\u6237\u7aef\u53d1\u9001\u8bf7\u6c42\u5230\u670d\u52a1\u5668&#xff0c;\u670d\u52a1\u5668\u63a5\u6536\u8bf7\u6c42\u540e\u5904\u7406\u5e76\u8fd4\u56de\u7ed3\u679c\u3002\u8fd9\u79cd\u6a21\u5f0f\u4e0b&#xff0c;\u5ba2\u6237\u7aef\u8d1f\u8d23\u63d0\u4f9b\u7528\u6237\u754c\u9762\u548c\u524d\u7aef\u903b\u8f91&#xff0c;\u800c\u670d\u52a1\u5668\u7aef\u5219\u5904\u7406\u590d\u6742\u7684\u4e1a\u52a1\u903b\u8f91\u548c\u6570\u636e\u5b58\u50a8\u3002 <\/p>\n<h3> 1.3 \u67b6\u6784\u6a21\u5f0f\u7684\u5b9e\u4f8b\u5e94\u7528 <\/h3>\n<p> Web\u6d4f\u89c8\u3001\u7535\u5b50\u90ae\u4ef6\u3001\u6587\u4ef6\u5171\u4eab\u7b49\u670d\u52a1\u90fd\u662f\u5ba2\u6237\u7aef-\u670d\u52a1\u5668\u67b6\u6784\u6a21\u5f0f\u7684\u5b9e\u9645\u5e94\u7528\u3002\u8fd9\u4e9b\u670d\u52a1\u90fd\u4f9d\u8d56\u4e8e\u670d\u52a1\u5668\u7aef\u7684\u7a33\u5b9a\u8fd0\u884c\u548c\u5ba2\u6237\u7aef\u7684\u6709\u6548\u8bf7\u6c42\u3002 <\/p>\n<p> \u6b64\u67b6\u6784\u6a21\u5f0f\u662f\u73b0\u4ee3\u7f51\u7edc\u670d\u52a1\u7684\u57fa\u77f3&#xff0c;\u7406\u89e3\u5b83\u7684\u57fa\u672c\u6982\u5ff5\u4e0e\u5de5\u4f5c\u6d41\u7a0b\u5bf9\u4e8eIT\u884c\u4e1a\u7684\u4e13\u4e1a\u4eba\u58eb\u6765\u8bf4\u81f3\u5173\u91cd\u8981\u3002\u5728\u540e\u7eed\u7ae0\u8282\u4e2d&#xff0c;\u6211\u4eec\u5c06\u6df1\u5165\u63a2\u8ba8\u5982\u4f55\u901a\u8fc7Socket\u63a5\u53e3\u5b9e\u73b0\u7f51\u7edc\u7f16\u7a0b&#xff0c;\u5e76\u4e86\u89e3TCP\/IP\u548cUDP\u534f\u8bae\u5728\u7f51\u7edc\u901a\u4fe1\u4e2d\u7684\u5177\u4f53\u5e94\u7528\u3002 <\/p>\n<h2> 2. \u7f51\u7edc\u7f16\u7a0b\u4e2d\u7684Socket\u63a5\u53e3 <\/h2>\n<h3> 2.1 Socket\u63a5\u53e3\u7684\u57fa\u672c\u6982\u5ff5\u4e0e\u4f5c\u7528 <\/h3>\n<h4> 2.1.1 Socket\u63a5\u53e3\u7684\u5b9a\u4e49\u548c\u5206\u7c7b <\/h4>\n<p> Socket&#xff0c;\u4e5f\u79f0\u4e3a\u5957\u63a5\u5b57&#xff0c;\u662f\u4e00\u79cd\u7f51\u7edc\u901a\u4fe1\u7684\u7aef\u70b9&#xff0c;\u5141\u8bb8\u4e24\u4e2a\u7a0b\u5e8f\u4e4b\u95f4\u8fdb\u884c\u6570\u636e\u4f20\u8f93\u3002\u5b83\u662f\u7f51\u7edc\u901a\u4fe1\u7684\u57fa\u7840&#xff0c;\u63d0\u4f9b\u4e86\u5e94\u7528\u7a0b\u5e8f\u4e0e\u7f51\u7edc\u534f\u8bae\u6808\u4e4b\u95f4\u7684\u62bd\u8c61\u5c42&#xff0c;\u4ee5\u4fbf\u8fdb\u884c\u6570\u636e\u4ea4\u6362\u3002 <\/p>\n<p> \u5728TCP\/IP\u534f\u8bae\u4e2d&#xff0c;\u5e38\u89c1\u7684Socket\u7c7b\u578b\u5305\u62ec\u6d41\u5f0f\u5957\u63a5\u5b57&#xff08;SOCK_STREAM&#xff09;\u548c\u6570\u636e\u62a5\u5957\u63a5\u5b57&#xff08;SOCK_DGRAM&#xff09;\u3002\u6d41\u5f0f\u5957\u63a5\u5b57\u57fa\u4e8eTCP\u534f\u8bae&#xff0c;\u63d0\u4f9b\u53ef\u9760\u3001\u6709\u5e8f\u3001\u65e0\u91cd\u590d\u7684\u5b57\u8282\u6d41\u4f20\u8f93&#xff0c;\u9002\u5408\u8981\u6c42\u9ad8\u53ef\u9760\u6027\u7684\u5e94\u7528\u3002\u6570\u636e\u62a5\u5957\u63a5\u5b57\u57fa\u4e8eUDP\u534f\u8bae&#xff0c;\u4f20\u8f93\u5feb\u901f\u4f46\u4e0d\u4fdd\u8bc1\u53ef\u9760\u6027&#xff0c;\u9002\u7528\u4e8e\u5bf9\u5b9e\u65f6\u6027\u8981\u6c42\u9ad8\u7684\u573a\u5408\u3002 <\/p>\n<h4> 2.1.2 Socket\u7f16\u7a0b\u7684\u5fc5\u8981\u6027\u548c\u5e94\u7528\u9886\u57df <\/h4>\n<p> Socket\u7f16\u7a0b\u662f\u7f51\u7edc\u5e94\u7528\u5f00\u53d1\u7684\u6838\u5fc3&#xff0c;\u65e0\u8bba\u662f\u7f51\u7edc\u670d\u52a1\u8fd8\u662f\u5ba2\u6237\u7aef\u7a0b\u5e8f&#xff0c;\u90fd\u79bb\u4e0d\u5f00Socket\u3002\u901a\u8fc7Socket&#xff0c;\u5f00\u53d1\u8005\u53ef\u4ee5\u5b9e\u73b0\u7f51\u7edc\u534f\u8bae\u81ea\u5b9a\u4e49\u3001\u6570\u636e\u901a\u4fe1\u3001\u8fdc\u7a0b\u8fc7\u7a0b\u8c03\u7528\u7b49\u3002 <\/p>\n<p> Socket\u7f16\u7a0b\u7684\u5e94\u7528\u9886\u57df\u975e\u5e38\u5e7f\u6cdb&#xff0c;\u5305\u62ec\u4f46\u4e0d\u9650\u4e8e&#xff1a; <\/p>\n<ul>\n<li> Web\u670d\u52a1\u548c\u5ba2\u6237\u7aef\u5e94\u7528 <\/li>\n<li> \u6587\u4ef6\u4f20\u8f93\u534f\u8bae&#xff08;FTP&#xff09;\u670d\u52a1\u5668\u4e0e\u5ba2\u6237\u7aef <\/li>\n<li> \u5b9e\u65f6\u901a\u4fe1\u670d\u52a1\u5982\u804a\u5929\u670d\u52a1\u5668 <\/li>\n<li> \u6e38\u620f\u670d\u52a1\u5668&#xff0c;\u5982\u591a\u4eba\u5728\u7ebf\u6e38\u620f <\/li>\n<li> \u8fdc\u7a0b\u76d1\u63a7\u548c\u7ba1\u7406\u7cfb\u7edf <\/li>\n<\/ul>\n<h3> 2.2 \u57fa\u4e8eSocket\u7684\u7f51\u7edc\u901a\u4fe1\u6a21\u578b <\/h3>\n<h4> 2.2.1 \u5ba2\u6237\u7aefSocket\u7684\u5efa\u7acb\u4e0e\u8fde\u63a5 <\/h4>\n<p> \u5ba2\u6237\u7aefSocket\u9700\u8981\u6307\u5b9a\u670d\u52a1\u5668\u7684IP\u5730\u5740\u548c\u7aef\u53e3\u53f7\u6765\u5efa\u7acb\u8fde\u63a5\u3002\u4ee5\u4e0b\u662f\u521b\u5efa\u4e00\u4e2aTCP\u5ba2\u6237\u7aefSocket\u7684\u4f2a\u4ee3\u7801&#xff1a; <\/p>\n<p>import socket<\/p>\n<p># \u521b\u5efa\u4e00\u4e2asocket\u5bf9\u8c61<br \/>\nclient_socket &#061; socket.socket(socket.AF_INET, socket.SOCK_STREAM)<\/p>\n<p># \u670d\u52a1\u5668\u7684IP\u5730\u5740\u548c\u7aef\u53e3\u53f7<br \/>\nserver_address &#061; (&#039;127.0.0.1&#039;, 12345)<\/p>\n<p># \u8fde\u63a5\u5230\u670d\u52a1\u5668<br \/>\nclient_socket.connect(server_address)<\/p>\n<p> \u5728\u8fd9\u6bb5\u4ee3\u7801\u4e2d&#xff0c;  socket.socket()  \u51fd\u6570\u521b\u5efa\u4e86\u4e00\u4e2a\u65b0\u7684Socket\u5bf9\u8c61&#xff0c;\u53c2\u6570  AF_INET  \u6307\u660e\u4f7f\u7528IPv4\u5730\u5740&#xff0c;  SOCK_STREAM  \u6307\u660e\u4f7f\u7528TCP\u534f\u8bae\u3002\u4e4b\u540e&#xff0c;\u4f7f\u7528  connect  \u65b9\u6cd5\u8fde\u63a5\u5230\u670d\u52a1\u5668\u3002 <\/p>\n<h4> 2.2.2 \u670d\u52a1\u5668\u7aefSocket\u7684\u76d1\u542c\u4e0e\u63a5\u53d7 <\/h4>\n<p> \u670d\u52a1\u5668\u7aefSocket\u9700\u8981\u7ed1\u5b9a\u5230\u7279\u5b9a\u7684IP\u5730\u5740\u548c\u7aef\u53e3\u53f7&#xff0c;\u5e76\u5f00\u59cb\u76d1\u542c\u8fde\u63a5\u8bf7\u6c42\u3002\u5f53\u6709\u5ba2\u6237\u7aef\u8bf7\u6c42\u8fde\u63a5\u65f6&#xff0c;\u670d\u52a1\u5668\u7aef\u9700\u8981\u63a5\u53d7\u8fd9\u4e2a\u8fde\u63a5\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684TCP\u670d\u52a1\u5668\u76d1\u542c\u5e76\u63a5\u53d7\u8fde\u63a5\u7684\u4f2a\u4ee3\u7801&#xff1a; <\/p>\n<p>import socket<\/p>\n<p># \u521b\u5efa\u4e00\u4e2asocket\u5bf9\u8c61<br \/>\nserver_socket &#061; socket.socket(socket.AF_INET, socket.SOCK_STREAM)<\/p>\n<p># \u7ed1\u5b9a\u5230\u6307\u5b9a\u7684IP\u5730\u5740\u548c\u7aef\u53e3\u53f7<br \/>\nserver_address &#061; (&#039;localhost&#039;, 12345)<br \/>\nserver_socket.bind(server_address)<\/p>\n<p># \u5f00\u59cb\u76d1\u542c\u8fde\u63a5\u8bf7\u6c42<br \/>\nserver_socket.listen(1)<\/p>\n<p># \u63a5\u53d7\u5ba2\u6237\u7aef\u8fde\u63a5<br \/>\nconnection, client_address &#061; server_socket.accept()<\/p>\n<p> \u5728\u4e0a\u8ff0\u4ee3\u7801\u4e2d&#xff0c;  bind  \u65b9\u6cd5\u5c06Socket\u7ed1\u5b9a\u5230\u6307\u5b9a\u7684\u5730\u5740\u548c\u7aef\u53e3\u4e0a&#xff0c;  listen  \u65b9\u6cd5\u4f7fSocket\u8fdb\u5165\u88ab\u52a8\u76d1\u542c\u72b6\u6001&#xff0c;\u53c2\u6570  1  \u8868\u793a\u5141\u8bb8\u7684\u6700\u5927\u8fde\u63a5\u6570\u3002  accept  \u65b9\u6cd5\u5219\u7528\u4e8e\u63a5\u53d7\u4e00\u4e2a\u5ba2\u6237\u7aef\u8fde\u63a5&#xff0c;\u5e76\u8fd4\u56de\u4e00\u4e2a\u65b0\u7684Socket\u5bf9\u8c61\u7528\u4e8e\u4e0e\u8be5\u5ba2\u6237\u7aef\u901a\u4fe1\u3002 <\/p>\n<h4> 2.2.3 \u6570\u636e\u7684\u53d1\u9001\u4e0e\u63a5\u6536\u673a\u5236 <\/h4>\n<p> \u6570\u636e\u7684\u53d1\u9001\u548c\u63a5\u6536\u662f\u901a\u8fc7\u8c03\u7528Socket\u5bf9\u8c61\u7684  send  \u548c  recv  \u65b9\u6cd5\u5b8c\u6210\u7684\u3002\u4ee5\u4e0b\u662f\u6570\u636e\u53d1\u9001\u548c\u63a5\u6536\u7684\u57fa\u672c\u793a\u4f8b&#xff1a; <\/p>\n<p># \u53d1\u9001\u6570\u636e<br \/>\nmessage &#061; &#039;Hello, world!&#039;<br \/>\nconnection.sendall(message.encode())<\/p>\n<p># \u63a5\u6536\u6570\u636e<br \/>\ndata &#061; connection.recv(1024)<\/p>\n<p>  sendall  \u65b9\u6cd5\u7528\u4e8e\u53d1\u9001\u5168\u90e8\u6570\u636e&#xff0c;\u800c  recv  \u65b9\u6cd5\u5219\u7528\u4e8e\u63a5\u6536\u6570\u636e&#xff0c;\u53c2\u6570  1024  \u6307\u5b9a\u6700\u5927\u63a5\u6536\u5b57\u8282\u6570\u3002\u5b9e\u9645\u5e94\u7528\u4e2d\u9700\u8981\u5904\u7406\u5f02\u5e38\u548c\u786e\u4fdd\u6570\u636e\u5b8c\u6574\u6027\u7684\u903b\u8f91\u3002 <\/p>\n<h3> 2.3 Socket\u7f16\u7a0b\u5b9e\u4f8b\u6f14\u793a <\/h3>\n<h4> 2.3.1 \u7b80\u5355\u7684Socket\u901a\u4fe1\u793a\u4f8b\u4ee3\u7801 <\/h4>\n<p> \u4e0b\u9762\u5c55\u793a\u4e86\u4e00\u4e2a\u7b80\u5355\u7684\u57fa\u4e8ePython\u7684Socket\u901a\u4fe1\u793a\u4f8b&#xff0c;\u5305\u62ec\u4e00\u4e2a\u670d\u52a1\u5668\u7aef\u548c\u4e00\u4e2a\u5ba2\u6237\u7aef&#xff1a; <\/p>\n<p># \u670d\u52a1\u5668\u7aef\u4ee3\u7801<br \/>\nimport socket<\/p>\n<p>server_socket &#061; socket.socket(socket.AF_INET, socket.SOCK_STREAM)<br \/>\nserver_address &#061; (&#039;localhost&#039;, 12345)<br \/>\nserver_socket.bind(server_address)<br \/>\nserver_socket.listen(1)<\/p>\n<p>connection, client_address &#061; server_socket.accept()<br \/>\ntry:<br \/>\n    print(&#039;Connection from:&#039;, client_address)<br \/>\n    while True:<br \/>\n        data &#061; connection.recv(1024)<br \/>\n        if data:<br \/>\n            print(&#039;Received data:&#039;, data.decode())<br \/>\n            response &#061; &#039;Acknowledged&#039;<br \/>\n            connection.sendall(response.encode())<br \/>\n        else:<br \/>\n            print(&#039;No data from&#039;, client_address)<br \/>\n            break<br \/>\nfinally:<br \/>\n    connection.close()<\/p>\n<p># \u5ba2\u6237\u7aef\u4ee3\u7801<br \/>\nimport socket<\/p>\n<p>client_socket &#061; socket.socket(socket.AF_INET, socket.SOCK_STREAM)<br \/>\nserver_address &#061; (&#039;localhost&#039;, 12345)<br \/>\nclient_socket.connect(server_address)<\/p>\n<p>try:<br \/>\n    message &#061; &#039;Hello, server!&#039;<br \/>\n    client_socket.sendall(message.encode())<br \/>\n    response &#061; client_socket.recv(1024)<br \/>\n    print(&#039;Received:&#039;, response.decode())<br \/>\nfinally:<br \/>\n    client_socket.close()<\/p>\n<p> \u4ee5\u4e0a\u4ee3\u7801\u5c55\u793a\u4e86\u5982\u4f55\u901a\u8fc7Socket\u5b9e\u73b0\u57fa\u672c\u7684\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u5668\u7aef\u901a\u4fe1\u3002\u670d\u52a1\u5668\u7aef\u5728\u6536\u5230\u5ba2\u6237\u7aef\u7684\u6d88\u606f\u540e\u53d1\u9001\u4e00\u4e2a\u786e\u8ba4\u6d88\u606f\u3002\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u5668\u7aef\u90fd\u4f7f\u7528\u4e86  try&#8230;finally  \u7ed3\u6784\u6765\u786e\u4fdd\u8fde\u63a5\u6b63\u786e\u5173\u95ed&#xff0c;\u5373\u4f7f\u5728\u53d1\u751f\u5f02\u5e38\u7684\u60c5\u51b5\u4e0b\u3002 <\/p>\n<h4> 2.3.2 \u591a\u7ebf\u7a0bSocket\u901a\u4fe1\u7684\u5b9e\u73b0 <\/h4>\n<p> \u5728\u9ad8\u5e76\u53d1\u7684\u7f51\u7edc\u5e94\u7528\u4e2d&#xff0c;\u4f7f\u7528\u591a\u7ebf\u7a0b\u53ef\u4ee5\u63d0\u9ad8\u670d\u52a1\u5668\u7684\u5904\u7406\u80fd\u529b\u3002\u4e0b\u9762\u7684\u793a\u4f8b\u5c55\u793a\u4e86\u5982\u4f55\u4f7f\u7528Python\u7684  threading  \u6a21\u5757\u6765\u5904\u7406\u591a\u4e2a\u5ba2\u6237\u7aef\u8fde\u63a5&#xff1a; <\/p>\n<p>import socket<br \/>\nimport threading<\/p>\n<p>def client_handler(connection):<br \/>\n    try:<br \/>\n        while True:<br \/>\n            data &#061; connection.recv(1024)<br \/>\n            if data:<br \/>\n                print(&#039;Received data:&#039;, data.decode())<br \/>\n                response &#061; &#039;Processed&#039;<br \/>\n                connection.sendall(response.encode())<br \/>\n            else:<br \/>\n                break<br \/>\n    finally:<br \/>\n        connection.close()<\/p>\n<p>server_socket &#061; socket.socket(socket.AF_INET, socket.SOCK_STREAM)<br \/>\nserver_address &#061; (&#039;localhost&#039;, 12345)<br \/>\nserver_socket.bind(server_address)<br \/>\nserver_socket.listen(5)<\/p>\n<p>while True:<br \/>\n    connection, client_address &#061; server_socket.accept()<br \/>\n    client_handler_thread &#061; threading.Thread(target&#061;client_handler, args&#061;(connection,))<br \/>\n    client_handler_thread.start()<\/p>\n<p> \u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d&#xff0c;\u6bcf\u5f53\u6709\u5ba2\u6237\u7aef\u8fde\u63a5\u65f6&#xff0c;\u670d\u52a1\u5668\u90fd\u4f1a\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u7ebf\u7a0b\u6765\u5904\u7406\u8be5\u8fde\u63a5\u3002  client_handler  \u51fd\u6570\u8d1f\u8d23\u4e0e\u5ba2\u6237\u7aef\u901a\u4fe1\u3002\u670d\u52a1\u5668\u4f7f\u7528\u4e00\u4e2a\u65e0\u9650\u5faa\u73af\u7b49\u5f85\u65b0\u7684\u8fde\u63a5\u3002 <\/p>\n<h4> 2.3.3 \u9ad8\u5e76\u53d1\u573a\u666f\u4e0b\u7684Socket\u4f7f\u7528\u7b56\u7565 <\/h4>\n<p> \u5728\u5904\u7406\u5927\u91cf\u5e76\u53d1\u8fde\u63a5\u65f6&#xff0c;\u9664\u4e86\u4f7f\u7528\u591a\u7ebf\u7a0b&#xff0c;\u8fd8\u53ef\u4ee5\u8003\u8651\u5176\u4ed6\u7b56\u7565&#xff1a; <\/p>\n<ul>\n<li>  I\/O\u591a\u8def\u590d\u7528  &#xff1a;\u4f7f\u7528  select  \u6216  poll  \u7b49\u7cfb\u7edf\u8c03\u7528\u5b9e\u73b0\u9ad8\u6548\u7684\u4e8b\u4ef6\u9a71\u52a8\u6a21\u578b&#xff0c;\u5355\u4e2a\u7ebf\u7a0b\u53ef\u4ee5\u76d1\u542c\u591a\u4e2aSocket\u7684\u4e8b\u4ef6\u3002 <\/li>\n<li>  \u5f02\u6b65I\/O  &#xff1a;\u4f7f\u7528\u5f02\u6b65\u7f16\u7a0b\u6a21\u578b&#xff0c;\u5982Python\u7684  asyncio  \u5e93&#xff0c;\u53ef\u4ee5\u66f4\u9ad8\u6548\u5730\u5904\u7406I\/O\u5bc6\u96c6\u578b\u4efb\u52a1\u3002 <\/li>\n<li>  \u975e\u963b\u585eSocket  &#xff1a;\u5c06Socket\u8bbe\u7f6e\u4e3a\u975e\u963b\u585e\u6a21\u5f0f&#xff0c;\u53ef\u4ee5\u5728\u6ca1\u6709\u6570\u636e\u65f6\u7acb\u5373\u8fd4\u56de&#xff0c;\u907f\u514d\u7ebf\u7a0b\u963b\u585e\u7b49\u5f85\u3002 <\/li>\n<li>  \u8d1f\u8f7d\u5747\u8861  &#xff1a;\u5728\u591a\u4e2a\u670d\u52a1\u5668\u4e4b\u95f4\u5206\u53d1\u6d41\u91cf&#xff0c;\u53ef\u4ee5\u4f7f\u7528\u786c\u4ef6\u8d1f\u8f7d\u5747\u8861\u5668\u6216\u8f6f\u4ef6\u8d1f\u8f7d\u5747\u8861\u7b56\u7565\u3002 <\/li>\n<\/ul>\n<p> \u6bcf\u79cd\u7b56\u7565\u90fd\u6709\u5176\u9002\u7528\u7684\u573a\u666f\u548c\u4f18\u7f3a\u70b9&#xff0c;\u5408\u7406\u9009\u62e9\u53ef\u4ee5\u5927\u5e45\u63d0\u5347\u7f51\u7edc\u5e94\u7528\u7684\u6027\u80fd\u548c\u7a33\u5b9a\u6027\u3002\u5728\u8bbe\u8ba1\u9ad8\u5e76\u53d1\u7684\u7f51\u7edc\u5e94\u7528\u65f6&#xff0c;\u9700\u8981\u7efc\u5408\u8003\u8651\u8d44\u6e90\u3001\u6027\u80fd\u548c\u53ef\u7ef4\u62a4\u6027\u3002 <\/p>\n<h2> 3. TCP\/IP\u548cUDP\u534f\u8bae\u5728\u7f51\u7edc\u901a\u4fe1\u4e2d\u7684\u5e94\u7528 <\/h2>\n<h3> 3.1 TCP\/IP\u534f\u8bae\u7c07\u7b80\u4ecb <\/h3>\n<h4> 3.1.1 TCP\/IP\u6a21\u578b\u4e0e\u5c42\u6b21\u7ed3\u6784 <\/h4>\n<p> TCP\/IP\u534f\u8bae\u7c07&#xff0c;\u662f\u4e00\u7ec4\u7528\u4e8e\u4e92\u8054\u7f51\u6570\u636e\u901a\u4fe1\u7684\u534f\u8bae\u3002\u5b83\u5e76\u975e\u5355\u4e2a\u534f\u8bae&#xff0c;\u800c\u662f\u4e00\u4e2a\u5305\u542b\u591a\u79cd\u534f\u8bae\u7684\u5927\u5bb6\u65cf\u3002\u8be5\u534f\u8bae\u7c07\u6700\u8457\u540d\u7684\u4e24\u4e2a\u6210\u5458\u662f\u4f20\u8f93\u63a7\u5236\u534f\u8bae&#xff08;TCP&#xff09;\u548c\u4e92\u8054\u7f51\u534f\u8bae&#xff08;IP&#xff09;&#xff0c;\u5176\u4e2dIP\u8d1f\u8d23\u5c06\u6570\u636e\u5305\u8def\u7531\u81f3\u76ee\u7684\u5730&#xff0c;TCP\u8d1f\u8d23\u5728\u4e24\u4e2a\u7f51\u7edc\u7cfb\u7edf\u95f4\u5efa\u7acb\u53ef\u9760\u8fde\u63a5\u5e76\u4f20\u8f93\u6570\u636e\u3002 <\/p>\n<p> TCP\/IP\u6a21\u578b\u5206\u4e3a\u56db\u4e2a\u5c42\u6b21&#xff1a;\u7f51\u7edc\u63a5\u53e3\u5c42\u3001\u4e92\u8054\u7f51\u5c42\u3001\u4f20\u8f93\u5c42\u548c\u5e94\u7528\u5c42\u3002 <\/p>\n<ul>\n<li>  \u7f51\u7edc\u63a5\u53e3\u5c42  &#xff1a;\u8d1f\u8d23\u5c06IP\u6570\u636e\u62a5\u5c01\u88c5\u6210\u5e27\u5e76\u5728\u7f51\u7edc\u4e0a\u53d1\u9001&#xff0c;\u6216\u5c06\u5e27\u89e3\u6790\u4e3aIP\u6570\u636e\u62a5\u3002\u5b83\u5bf9\u5e94\u7684\u662f\u6570\u636e\u94fe\u8def\u5c42\u548c\u7269\u7406\u5c42\u3002 <\/li>\n<li>  \u4e92\u8054\u7f51\u5c42  &#xff1a;\u4e3b\u8981\u5b9e\u73b0\u7f51\u7edc\u4e4b\u95f4\u7684\u6570\u636e\u4f20\u8f93\u3002\u5b83\u4e3b\u8981\u529f\u80fd\u662f\u5904\u7406IP\u6570\u636e\u62a5\u7684\u8def\u7531&#xff0c;\u4ee5\u53ca\u6570\u636e\u62a5\u7684\u5206\u7247\u4e0e\u91cd\u7ec4\u3002 <\/li>\n<li>  \u4f20\u8f93\u5c42  &#xff1a;\u63d0\u4f9b\u7aef\u5230\u7aef\u7684\u6570\u636e\u4f20\u8f93\u3002TCP\u548c\u7528\u6237\u6570\u636e\u62a5\u534f\u8bae&#xff08;UDP&#xff09;\u662f\u8be5\u5c42\u7684\u4e3b\u8981\u534f\u8bae\u3002TCP\u63d0\u4f9b\u53ef\u9760\u7684\u3001\u9762\u5411\u8fde\u63a5\u7684\u670d\u52a1&#xff0c;\u800cUDP\u63d0\u4f9b\u4e0d\u53ef\u9760\u7684\u3001\u65e0\u8fde\u63a5\u7684\u670d\u52a1\u3002 <\/li>\n<li>  \u5e94\u7528\u5c42  &#xff1a;\u5904\u7406\u7279\u5b9a\u5e94\u7528\u7684\u7ec6\u8282\u3002\u8fd9\u4e00\u5c42\u7684\u534f\u8bae\u6709HTTP\u3001FTP\u3001SMTP\u7b49&#xff0c;\u5b83\u4eec\u5b9a\u4e49\u4e86\u5e94\u7528\u5982\u4f55\u5728\u4f20\u8f93\u5c42\u4e4b\u4e0a\u8fdb\u884c\u4ea4\u4e92\u3002 <\/li>\n<\/ul>\n<h4> 3.1.2 TCP\u4e0eUDP\u534f\u8bae\u7684\u7279\u70b9\u548c\u9009\u62e9 <\/h4>\n<p> \u5728TCP\/IP\u6a21\u578b\u4e2d&#xff0c;TCP\u548cUDP\u662f\u6700\u5e38\u7528\u7684\u4e24\u4e2a\u534f\u8bae\u3002\u5b83\u4eec\u5404\u81ea\u6709\u4e0d\u540c\u7684\u7279\u70b9\u548c\u9002\u7528\u573a\u666f\u3002 <\/p>\n<p>  TCP&#xff08;\u4f20\u8f93\u63a7\u5236\u534f\u8bae&#xff09;  <\/p>\n<p> TCP\u63d0\u4f9b\u7684\u662f\u9762\u5411\u8fde\u63a5\u7684\u670d\u52a1&#xff0c;\u5b83\u786e\u4fdd\u6570\u636e\u5305\u6309\u7167\u6b63\u786e\u7684\u987a\u5e8f\u5230\u8fbe&#xff0c;\u5e76\u4e14\u4e22\u5931\u7684\u6570\u636e\u5305\u4f1a\u5f97\u5230\u91cd\u4f20\u3002TCP\u9002\u5408\u4e8e\u5bf9\u6570\u636e\u4f20\u8f93\u53ef\u9760\u6027\u8981\u6c42\u9ad8\u7684\u5e94\u7528&#xff0c;\u5982\u7f51\u9875\u6d4f\u89c8\u3001\u6587\u4ef6\u4f20\u8f93\u3001\u7535\u5b50\u90ae\u4ef6\u7b49\u3002 <\/p>\n<p> TCP\u7684\u8fde\u63a5\u8fc7\u7a0b\u9700\u8981\u7ecf\u8fc7\u201c\u4e09\u6b21\u63e1\u624b\u201d&#xff0c;\u4ee5\u786e\u8ba4\u53cc\u65b9\u7684\u63a5\u6536\u548c\u53d1\u9001\u80fd\u529b\u3002\u6570\u636e\u4f20\u8f93\u5b8c\u6210\u540e&#xff0c;\u8fd8\u9700\u8981\u8fdb\u884c\u201c\u56db\u6b21\u6325\u624b\u201d\u6765\u65ad\u5f00\u8fde\u63a5\u3002 <\/p>\n<p>  UDP&#xff08;\u7528\u6237\u6570\u636e\u62a5\u534f\u8bae&#xff09;  <\/p>\n<p> UDP\u63d0\u4f9b\u7684\u662f\u65e0\u8fde\u63a5\u7684\u670d\u52a1&#xff0c;\u53d1\u9001\u7684\u6570\u636e\u5305\u4e4b\u95f4\u6ca1\u6709\u987a\u5e8f&#xff0c;\u4e5f\u4e0d\u4fdd\u8bc1\u6570\u636e\u5305\u7684\u53ef\u9760\u5230\u8fbe\u3002UDP\u9002\u7528\u4e8e\u90a3\u4e9b\u5bf9\u5b9e\u65f6\u6027\u8981\u6c42\u9ad8&#xff0c;\u4f46\u53ef\u4ee5\u5bb9\u5fcd\u4e00\u5b9a\u4e22\u5305\u7684\u573a\u666f&#xff0c;\u5982\u5728\u7ebf\u89c6\u9891\u3001\u5728\u7ebf\u6e38\u620f\u548c\u5b9e\u65f6\u8bed\u97f3\u901a\u4fe1\u3002 <\/p>\n<p> UDP\u56e0\u4e3a\u6ca1\u6709\u590d\u6742\u7684\u8fde\u63a5\u7ba1\u7406&#xff0c;\u6240\u4ee5\u5f00\u9500\u4f4e&#xff0c;\u4f20\u8f93\u6548\u7387\u9ad8&#xff0c;\u4f46\u662f\u9700\u8981\u5e94\u7528\u5c42\u6765\u5904\u7406\u4e22\u5305\u3001\u91cd\u4f20\u7b49\u53ef\u9760\u6027\u95ee\u9898\u3002 <\/p>\n<p> \u5728\u9009\u62e9TCP\u6216UDP\u65f6&#xff0c;\u9700\u8981\u8003\u8651\u5e94\u7528\u7684\u5b9e\u9645\u9700\u6c42&#xff0c;\u5305\u62ec\u6570\u636e\u7684\u5927\u5c0f\u3001\u5b9e\u65f6\u6027\u8981\u6c42\u3001\u7f51\u7edc\u7684\u53ef\u9760\u6027\u7b49\u56e0\u7d20\u3002 <\/p>\n<h3> 3.2 TCP\u534f\u8bae\u7684\u8fde\u63a5\u7ba1\u7406\u548c\u6570\u636e\u4f20\u8f93 <\/h3>\n<h4> 3.2.1 \u4e09\u6b21\u63e1\u624b\u4e0e\u56db\u6b21\u6325\u624b\u8fc7\u7a0b <\/h4>\n<p> TCP\u901a\u8fc7\u4e09\u6b21\u63e1\u624b\u5efa\u7acb\u8fde\u63a5\u3002\u4ee5\u4e0b\u662f\u4e09\u6b21\u63e1\u624b\u7684\u8be6\u7ec6\u6b65\u9aa4&#xff1a; <\/p>\n<li> \u5ba2\u6237\u7aef\u53d1\u9001\u4e00\u4e2a\u5e26\u6709SYN\u6807\u5fd7\u4f4d\u7684\u6570\u636e\u5305\u7ed9\u670d\u52a1\u5668&#xff0c;\u8868\u793a\u8bf7\u6c42\u8fde\u63a5\u3002 <\/li>\n<li> \u670d\u52a1\u5668\u6536\u5230\u5ba2\u6237\u7aef\u7684SYN\u8bf7\u6c42\u540e&#xff0c;\u56de\u5e94\u4e00\u4e2a\u5e26\u6709SYN\/ACK\u6807\u5fd7\u4f4d\u7684\u6570\u636e\u5305&#xff0c;\u786e\u8ba4\u8fde\u63a5\u8bf7\u6c42&#xff0c;\u5e76\u7b49\u5f85\u5ba2\u6237\u7aef\u786e\u8ba4\u3002 <\/li>\n<li> \u5ba2\u6237\u7aef\u6536\u5230\u670d\u52a1\u5668\u7684SYN\/ACK\u540e&#xff0c;\u53d1\u9001\u4e00\u4e2a\u5e26\u6709ACK\u6807\u5fd7\u4f4d\u7684\u6570\u636e\u5305&#xff0c;\u5b8c\u6210\u8fde\u63a5\u5efa\u7acb\u3002 <\/li>\n<p> \u5728\u6570\u636e\u4f20\u8f93\u7ed3\u675f\u540e&#xff0c;\u9700\u8981\u56db\u6b21\u6325\u624b\u65ad\u5f00\u8fde\u63a5\u3002\u4ee5\u4e0b\u662f\u56db\u6b21\u6325\u624b\u7684\u8be6\u7ec6\u6b65\u9aa4&#xff1a; <\/p>\n<li> \u5ba2\u6237\u7aef\u60f3\u8981\u7ed3\u675f\u8fde\u63a5\u65f6&#xff0c;\u53d1\u9001\u4e00\u4e2a\u5e26\u6709FIN\u6807\u5fd7\u4f4d\u7684\u6570\u636e\u5305\u7ed9\u670d\u52a1\u5668\u3002 <\/li>\n<li> \u670d\u52a1\u5668\u6536\u5230FIN\u8bf7\u6c42\u540e&#xff0c;\u53d1\u9001\u4e00\u4e2a\u5e26\u6709ACK\u6807\u5fd7\u4f4d\u7684\u6570\u636e\u5305&#xff0c;\u8868\u793a\u5df2\u63a5\u6536\u65ad\u5f00\u8bf7\u6c42&#xff0c;\u4f46\u670d\u52a1\u5668\u8fd8\u53ef\u4ee5\u7ee7\u7eed\u53d1\u9001\u6570\u636e\u3002 <\/li>\n<li> \u5f53\u670d\u52a1\u5668\u6570\u636e\u53d1\u9001\u5b8c\u6bd5&#xff0c;\u53d1\u9001\u4e00\u4e2aFIN\u6570\u636e\u5305\u7ed9\u5ba2\u6237\u7aef&#xff0c;\u8868\u793a\u5141\u8bb8\u65ad\u5f00\u8fde\u63a5\u3002 <\/li>\n<li> \u5ba2\u6237\u7aef\u6536\u5230\u670d\u52a1\u5668\u7684FIN\u540e&#xff0c;\u53d1\u9001\u4e00\u4e2aACK\u6570\u636e\u5305&#xff0c;\u7136\u540e\u7b49\u5f852MSL\u65f6\u95f4\u540e&#xff0c;\u65ad\u5f00\u8fde\u63a5\u3002 <\/li>\n<h4> 3.2.2 \u6d41\u91cf\u63a7\u5236\u4e0e\u62e5\u585e\u63a7\u5236\u673a\u5236 <\/h4>\n<p> \u4e3a\u4e86\u4fdd\u8bc1\u7f51\u7edc\u7684\u7a33\u5b9a\u6027\u548c\u6570\u636e\u4f20\u8f93\u7684\u9ad8\u6548\u6027&#xff0c;TCP\u91c7\u53d6\u4e86\u6d41\u91cf\u63a7\u5236\u548c\u62e5\u585e\u63a7\u5236\u673a\u5236\u3002 <\/p>\n<p>  \u6d41\u91cf\u63a7\u5236  <\/p>\n<p> \u6d41\u91cf\u63a7\u5236\u662f\u4e3a\u4e86\u907f\u514d\u53d1\u9001\u65b9\u53d1\u9001\u6570\u636e\u8fc7\u5feb\u5bfc\u81f4\u63a5\u6536\u65b9\u6765\u4e0d\u53ca\u5904\u7406\u3002TCP\u5229\u7528\u6ed1\u52a8\u7a97\u53e3\u673a\u5236\u5b9e\u73b0\u6d41\u91cf\u63a7\u5236\u3002\u7a97\u53e3\u5927\u5c0f\u5728TCP\u5934\u90e8\u4e2d\u8868\u793a&#xff0c;\u5b83\u53cd\u6620\u4e86\u53d1\u9001\u65b9\u8fd8\u53ef\u4ee5\u53d1\u9001\u591a\u5c11\u5b57\u8282\u7684\u6570\u636e\u800c\u65e0\u9700\u7b49\u5f85\u786e\u8ba4\u3002 <\/p>\n<p>  \u62e5\u585e\u63a7\u5236  <\/p>\n<p> \u62e5\u585e\u63a7\u5236\u662f\u4e3a\u4e86\u9632\u6b62\u8fc7\u591a\u7684\u6570\u636e\u6ce8\u5165\u5230\u7f51\u7edc\u4e2d&#xff0c;\u5bfc\u81f4\u7f51\u7edc\u4e2d\u7684\u8def\u7531\u5668\u6216\u94fe\u8def\u8fc7\u8f7d\u3002\u62e5\u585e\u63a7\u5236\u7684\u65b9\u6cd5\u4e3b\u8981\u6709\u56db\u79cd&#xff1a; <\/p>\n<ul>\n<li> \u6162\u542f\u52a8&#xff08;Slow Start&#xff09; <\/li>\n<li> \u62e5\u585e\u907f\u514d&#xff08;Congestion Avoidance&#xff09; <\/li>\n<li> \u5feb\u901f\u91cd\u4f20&#xff08;Fast Retransmit&#xff09; <\/li>\n<li> \u5feb\u901f\u6062\u590d&#xff08;Fast Recovery&#xff09; <\/li>\n<\/ul>\n<p> \u901a\u8fc7\u8fd9\u4e9b\u65b9\u6cd5&#xff0c;TCP\u53ef\u4ee5\u52a8\u6001\u8c03\u6574\u62e5\u585e\u7a97\u53e3\u7684\u5927\u5c0f&#xff0c;\u4ece\u800c\u63a7\u5236\u6570\u636e\u53d1\u9001\u7684\u901f\u7387\u3002 <\/p>\n<h4> 3.2.3 TCP\u534f\u8bae\u7684\u53ef\u9760\u6027\u4fdd\u8bc1 <\/h4>\n<p> TCP\u901a\u8fc7\u4e00\u7cfb\u5217\u673a\u5236\u4fdd\u8bc1\u6570\u636e\u4f20\u8f93\u7684\u53ef\u9760\u6027&#xff0c;\u4e3b\u8981\u5305\u62ec\u4ee5\u4e0b\u51e0\u4e2a\u65b9\u9762&#xff1a; <\/p>\n<ul>\n<li>  \u5e8f\u5217\u53f7\u4e0e\u786e\u8ba4\u5e94\u7b54  &#xff1a;\u6bcf\u4e2a\u53d1\u9001\u7684\u6570\u636e\u5305\u90fd\u5e26\u6709\u5e8f\u5217\u53f7&#xff0c;\u63a5\u6536\u65b9\u901a\u8fc7\u8fd4\u56de\u5e26\u6709\u5e8f\u5217\u53f7\u7684\u786e\u8ba4\u5e94\u7b54\u6765\u786e\u8ba4\u6570\u636e\u7684\u6b63\u786e\u63a5\u6536\u3002 <\/li>\n<li>  \u91cd\u4f20\u673a\u5236  &#xff1a;\u5982\u679c\u53d1\u9001\u65b9\u5728\u6307\u5b9a\u65f6\u95f4\u5185\u672a\u6536\u5230\u786e\u8ba4\u5e94\u7b54&#xff0c;\u4f1a\u91cd\u65b0\u53d1\u9001\u6570\u636e\u5305\u3002 <\/li>\n<li>  \u6821\u9a8c\u548c  &#xff1a;\u6bcf\u4e2a\u6570\u636e\u5305\u90fd\u643a\u5e26\u4e00\u4e2a\u6821\u9a8c\u548c&#xff0c;\u7528\u4e8e\u68c0\u67e5\u4f20\u8f93\u8fc7\u7a0b\u4e2d\u6570\u636e\u662f\u5426\u635f\u574f\u3002 <\/li>\n<li>  \u6570\u636e\u5305\u6392\u5e8f  &#xff1a;\u63a5\u6536\u65b9\u4f1a\u5bf9\u5230\u8fbe\u7684\u6570\u636e\u5305\u8fdb\u884c\u6392\u5e8f&#xff0c;\u786e\u4fdd\u6570\u636e\u6309\u6b63\u786e\u7684\u987a\u5e8f\u91cd\u7ec4\u3002 <\/li>\n<\/ul>\n<h3> 3.3 UDP\u534f\u8bae\u7684\u7279\u70b9\u53ca\u5e94\u7528\u5b9e\u4f8b <\/h3>\n<h4> 3.3.1 UDP\u534f\u8bae\u7684\u5de5\u4f5c\u65b9\u5f0f\u548c\u4f18\u52bf <\/h4>\n<p> UDP\u662f\u4e00\u4e2a\u65e0\u8fde\u63a5\u7684\u534f\u8bae&#xff0c;\u5b83\u5728IP\u534f\u8bae\u4e4b\u4e0a\u589e\u52a0\u4e86\u4e00\u70b9\u63a7\u5236\u529f\u80fd\u3002\u7531\u4e8eUDP\u7b80\u5355&#xff0c;\u5b83\u51e0\u4e4e\u6ca1\u6709\u5f00\u9500&#xff0c;\u63d0\u4f9b\u4e00\u79cd\u201c\u5c3d\u529b\u800c\u4e3a\u201d\u7684\u6570\u636e\u4f20\u8f93\u670d\u52a1\u3002 <\/p>\n<p> UDP\u7684\u4e3b\u8981\u7279\u70b9\u548c\u4f18\u52bf\u5982\u4e0b&#xff1a; <\/p>\n<ul>\n<li>  \u65e0\u8fde\u63a5  &#xff1a;\u53d1\u9001\u6570\u636e\u524d\u4e0d\u9700\u8981\u5efa\u7acb\u8fde\u63a5&#xff0c;\u8282\u7701\u65f6\u95f4\u3002 <\/li>\n<li>  \u5f00\u9500\u5c0f  &#xff1a;\u7531\u4e8e\u4e0d\u9700\u8981\u7ef4\u62a4\u8fde\u63a5\u72b6\u6001&#xff0c;UDP\u5934\u90e8\u7684\u5f00\u9500\u5c0f&#xff08;\u4ec58\u5b57\u8282&#xff09;\u3002 <\/li>\n<li>  \u4f20\u8f93\u901f\u5ea6\u5feb  &#xff1a;\u7531\u4e8e\u5c11\u4e86\u63e1\u624b\u3001\u786e\u8ba4\u5e94\u7b54\u7b49\u8fc7\u7a0b&#xff0c;\u53d1\u9001\u548c\u63a5\u6536\u6570\u636e\u7684\u901f\u5ea6\u5feb\u3002 <\/li>\n<li>  \u9002\u7528\u4e8e\u591a\u64ad\u548c\u5e7f\u64ad  &#xff1a;UDP\u652f\u6301\u4e00\u5bf9\u591a\u7684\u901a\u4fe1&#xff0c;\u7279\u522b\u9002\u5408\u76f4\u64ad\u6d41\u5a92\u4f53\u7b49\u5e94\u7528\u3002 <\/li>\n<\/ul>\n<h4> 3.3.2 \u5728\u5b9e\u65f6\u5e94\u7528\u4e2dUDP\u7684\u4f7f\u7528\u573a\u666f <\/h4>\n<p> \u5728\u9700\u8981\u5b9e\u65f6\u901a\u4fe1\u7684\u5e94\u7528\u4e2d&#xff0c;\u5982\u5728\u7ebf\u6e38\u620f\u3001\u89c6\u9891\u4f1a\u8bae\u3001\u5b9e\u65f6\u8bed\u97f3\u901a\u8bdd\u7b49&#xff0c;UDP\u901a\u5e38\u662f\u4e00\u4e2a\u66f4\u597d\u7684\u9009\u62e9\u3002\u4f8b\u5982&#xff0c;\u5728\u4e00\u4e2a\u591a\u4eba\u5728\u7ebf\u6e38\u620f\u573a\u666f\u4e2d&#xff0c;\u6e38\u620f\u5ba2\u6237\u7aef\u9700\u8981\u5b9e\u65f6\u63a5\u6536\u6765\u81ea\u670d\u52a1\u5668\u7684\u6e38\u620f\u72b6\u6001\u66f4\u65b0\u3002\u4f7f\u7528UDP\u53ef\u4ee5\u51cf\u5c11\u5ef6\u8fdf&#xff0c;\u63d0\u5347\u73a9\u5bb6\u7684\u6e38\u620f\u4f53\u9a8c\u3002 <\/p>\n<h4> 3.3.3 UDP\u4e0eTCP\u7684\u6027\u80fd\u6bd4\u8f83\u5206\u6790 <\/h4>\n<p> UDP\u548cTCP\u5728\u6027\u80fd\u4e0a\u6709\u5f88\u5927\u7684\u5dee\u5f02&#xff0c;\u5c24\u5176\u662f\u5728\u5ef6\u8fdf\u3001\u5e26\u5bbd\u5229\u7528\u7387\u548c\u8d44\u6e90\u6d88\u8017\u7b49\u65b9\u9762\u3002 <\/p>\n<ul>\n<li>  \u5ef6\u8fdf  &#xff1a;UDP\u7531\u4e8e\u4e0d\u9700\u8981\u63e1\u624b\u548c\u786e\u8ba4\u673a\u5236&#xff0c;\u5ef6\u8fdf\u4f1a\u66f4\u4f4e\u3002 <\/li>\n<li>  \u5e26\u5bbd\u5229\u7528\u7387  &#xff1a;\u5728\u9ad8\u5e26\u5bbd\u5229\u7528\u7387\u573a\u666f\u4e0b&#xff0c;UDP\u4f1a\u66f4\u6709\u6548\u7387&#xff0c;\u56e0\u4e3aTCP\u7684\u62e5\u585e\u63a7\u5236\u548c\u6d41\u91cf\u63a7\u5236\u53ef\u80fd\u4f1a\u9650\u5236\u53d1\u9001\u901f\u7387\u3002 <\/li>\n<li>  \u8d44\u6e90\u6d88\u8017  &#xff1a;TCP\u6d88\u8017\u7684\u7cfb\u7edf\u8d44\u6e90\u66f4\u591a&#xff0c;\u56e0\u4e3a\u5b83\u9700\u8981\u7ef4\u62a4\u8fde\u63a5\u72b6\u6001&#xff0c;\u800cUDP\u4e0d\u9700\u8981\u3002 <\/li>\n<li>  \u53ef\u9760\u6027  &#xff1a;TCP\u63d0\u4f9b\u4e86\u53ef\u9760\u7684\u6570\u636e\u4f20\u8f93&#xff0c;\u800cUDP\u6ca1\u6709\u63d0\u4f9b&#xff0c;\u56e0\u6b64\u5728\u53ef\u9760\u6027\u8981\u6c42\u8f83\u9ad8\u7684\u5e94\u7528\u4e2d&#xff0c;\u9700\u8981\u5728\u5e94\u7528\u5c42\u5b9e\u73b0\u53ef\u9760\u6027\u673a\u5236\u3002 <\/li>\n<\/ul>\n<p> \u9009\u62e9UDP\u8fd8\u662fTCP&#xff0c;\u53d6\u51b3\u4e8e\u5e94\u7528\u7684\u9700\u6c42\u3002\u5bf9\u4e8e\u5bf9\u5b9e\u65f6\u6027\u8981\u6c42\u9ad8\u4e14\u53ef\u4ee5\u5bb9\u5fcd\u4e00\u5b9a\u4e22\u5305\u7684\u5e94\u7528&#xff0c;UDP\u662f\u4e00\u4e2a\u66f4\u4f18\u7684\u9009\u62e9\u3002\u5bf9\u4e8e\u9700\u8981\u786e\u4fdd\u6570\u636e\u5b8c\u6574\u6027\u548c\u987a\u5e8f\u7684\u5e94\u7528&#xff0c;TCP\u662f\u66f4\u5408\u9002\u7684\u9009\u62e9\u3002 <\/p>\n<h2> 4. \u767b\u5f55\u3001\u6ce8\u518c\u3001\u804a\u5929\u7cfb\u7edf\u5b9e\u73b0\u65b9\u6cd5 <\/h2>\n<p> \u5728\u73b0\u4ee3\u4e92\u8054\u7f51\u5e94\u7528\u4e2d&#xff0c;\u767b\u5f55\u3001\u6ce8\u518c\u3001\u804a\u5929\u7cfb\u7edf\u662f\u6784\u6210\u57fa\u7840\u4ea4\u4e92\u529f\u80fd\u7684\u6838\u5fc3\u90e8\u5206\u3002\u5b83\u4eec\u5404\u81ea\u9700\u8981\u72ec\u7acb\u7684\u673a\u5236\u6765\u4fdd\u969c\u7528\u6237\u7684\u4f7f\u7528\u4f53\u9a8c\u548c\u7cfb\u7edf\u7684\u5b89\u5168\u3002\u672c\u7ae0\u5c06\u5bf9\u8fd9\u4e9b\u7cfb\u7edf\u7684\u5b9e\u73b0\u65b9\u6cd5\u8fdb\u884c\u6df1\u5165\u63a2\u8ba8&#xff0c;\u4ece\u7528\u6237\u8eab\u4efd\u9a8c\u8bc1\u673a\u5236\u5230\u804a\u5929\u7cfb\u7edf\u7684\u8bbe\u8ba1\u8981\u70b9&#xff0c;\u518d\u5230\u7cfb\u7edf\u96c6\u6210\u4e0e\u6d4b\u8bd5\u3002 <\/p>\n<h3> 4.1 \u7528\u6237\u8eab\u4efd\u9a8c\u8bc1\u673a\u5236 <\/h3>\n<h4> 4.1.1 \u767b\u5f55\u7cfb\u7edf\u7684\u8bbe\u8ba1\u4e0e\u5b9e\u73b0 <\/h4>\n<p> \u767b\u5f55\u7cfb\u7edf\u662f\u7528\u6237\u4e0e\u5e94\u7528\u4ea4\u4e92\u7684\u7b2c\u4e00\u9053\u5927\u95e8\u3002\u5b83\u7684\u8bbe\u8ba1\u4e0e\u5b9e\u73b0\u5fc5\u987b\u517c\u987e\u7528\u6237\u4f53\u9a8c\u548c\u5b89\u5168\u6027\u3002\u901a\u5e38&#xff0c;\u767b\u5f55\u7cfb\u7edf\u4f1a\u8981\u6c42\u7528\u6237\u63d0\u4f9b\u51ed\u8bc1&#xff0c;\u5982\u7528\u6237\u540d\u548c\u5bc6\u7801&#xff0c;\u8fd9\u4e9b\u51ed\u8bc1\u901a\u8fc7\u5b89\u5168\u7684\u901a\u9053\u53d1\u9001\u5230\u670d\u52a1\u5668\u8fdb\u884c\u9a8c\u8bc1\u3002 <\/p>\n<h5> 4.1.1.1 \u51ed\u8bc1\u9a8c\u8bc1\u6d41\u7a0b <\/h5>\n<li>  \u7528\u6237\u8f93\u5165  &#xff1a;\u7528\u6237\u5728\u767b\u5f55\u754c\u9762\u8f93\u5165\u7528\u6237\u540d\u548c\u5bc6\u7801\u3002 <\/li>\n<li>  \u5ba2\u6237\u7aef\u5c01\u88c5  &#xff1a;\u5c06\u8f93\u5165\u7684\u51ed\u8bc1\u8fdb\u884c\u52a0\u5bc6\u5904\u7406&#xff0c;\u7136\u540e\u53d1\u9001\u5230\u670d\u52a1\u5668\u3002 <\/li>\n<li>  \u670d\u52a1\u5668\u5904\u7406  &#xff1a;\u670d\u52a1\u5668\u63a5\u6536\u5230\u52a0\u5bc6\u540e\u7684\u51ed\u8bc1&#xff0c;\u8fdb\u884c\u89e3\u5bc6&#xff0c;\u7136\u540e\u4e0e\u6570\u636e\u5e93\u4e2d\u5b58\u50a8\u7684\u51ed\u8bc1\u8fdb\u884c\u6bd4\u5bf9\u3002 <\/li>\n<li>  \u9a8c\u8bc1\u7ed3\u679c  &#xff1a;\u5982\u679c\u51ed\u8bc1\u5339\u914d&#xff0c;\u5219\u6388\u4e88\u7528\u6237\u8bbf\u95ee\u6743\u9650&#xff1b;\u5982\u679c\u4e0d\u5339\u914d&#xff0c;\u5219\u8fd4\u56de\u767b\u5f55\u5931\u8d25\u4fe1\u606f\u3002 <\/li>\n<h5> 4.1.1.2 \u5b89\u5168\u901a\u4fe1 <\/h5>\n<p> \u4e3a\u4e86\u9632\u6b62\u51ed\u8bc1\u5728\u4f20\u8f93\u8fc7\u7a0b\u4e2d\u88ab\u622a\u83b7&#xff0c;\u5e94\u8be5\u4f7f\u7528\u5b89\u5168\u7684\u901a\u4fe1\u534f\u8bae&#xff0c;\u5982HTTPS\u3002HTTPS\u53ef\u4ee5\u9632\u6b62\u4e2d\u95f4\u4eba\u653b\u51fb&#xff0c;\u4fdd\u8bc1\u6570\u636e\u7684\u673a\u5bc6\u6027\u548c\u5b8c\u6574\u6027\u3002 <\/p>\n<h5> 4.1.1.3 \u767b\u5f55\u51ed\u8bc1\u7684\u5b58\u50a8 <\/h5>\n<p> \u5728\u670d\u52a1\u5668\u7aef&#xff0c;\u7528\u6237\u7684\u767b\u5f55\u51ed\u8bc1\u4e0d\u5e94\u8be5\u4ee5\u660e\u6587\u5f62\u5f0f\u5b58\u50a8\u3002\u5e38\u89c1\u7684\u505a\u6cd5\u662f\u4f7f\u7528\u54c8\u5e0c\u52a0\u76d0\u7684\u65b9\u5f0f\u6765\u5b58\u50a8\u5bc6\u7801\u7684\u54c8\u5e0c\u503c\u3002\u8fd9\u6837\u5373\u4f7f\u6570\u636e\u5e93\u88ab\u6cc4\u9732&#xff0c;\u653b\u51fb\u8005\u4e5f\u96be\u4ee5\u8fd8\u539f\u51fa\u539f\u59cb\u5bc6\u7801\u3002 <\/p>\n<h4> 4.1.2 \u6ce8\u518c\u6d41\u7a0b\u53ca\u6570\u636e\u5b58\u50a8\u65b9\u6848 <\/h4>\n<p> \u6ce8\u518c\u6d41\u7a0b\u5141\u8bb8\u65b0\u7528\u6237\u521b\u5efa\u8d26\u6237&#xff0c;\u662f\u7528\u6237\u8fdb\u5165\u7cfb\u7edf\u7684\u5165\u53e3\u3002\u6ce8\u518c\u6d41\u7a0b\u9700\u8981\u8003\u8651\u4fe1\u606f\u7684\u6536\u96c6\u3001\u9a8c\u8bc1\u548c\u5b58\u50a8\u3002 <\/p>\n<h5> 4.1.2.1 \u7528\u6237\u4fe1\u606f\u7684\u6536\u96c6 <\/h5>\n<p> \u5728\u6ce8\u518c\u8fc7\u7a0b\u4e2d&#xff0c;\u9700\u8981\u7528\u6237\u8f93\u5165\u7684\u4fe1\u606f\u901a\u5e38\u5305\u62ec\u7528\u6237\u540d\u3001\u5bc6\u7801\u3001\u90ae\u7bb1\u3001\u624b\u673a\u53f7\u7801\u7b49\u3002\u6839\u636e\u5e94\u7528\u7684\u4e0d\u540c&#xff0c;\u8fd8\u53ef\u80fd\u9700\u8981\u6536\u96c6\u7528\u6237\u7684\u5176\u4ed6\u4fe1\u606f&#xff0c;\u5982\u751f\u65e5\u3001\u6027\u522b\u3001\u4f4d\u7f6e\u7b49\u3002 <\/p>\n<h5> 4.1.2.2 \u9a8c\u8bc1\u6d41\u7a0b <\/h5>\n<ul>\n<li>  \u90ae\u7bb1\u9a8c\u8bc1  &#xff1a;\u53d1\u9001\u4e00\u5c01\u542b\u6709\u9a8c\u8bc1\u94fe\u63a5\u7684\u90ae\u4ef6\u5230\u7528\u6237\u6ce8\u518c\u90ae\u7bb1&#xff0c;\u7528\u6237\u70b9\u51fb\u94fe\u63a5\u540e\u5b8c\u6210\u90ae\u7bb1\u9a8c\u8bc1\u3002 <\/li>\n<li>  \u624b\u673a\u9a8c\u8bc1  &#xff1a;\u53d1\u9001\u4e00\u4e2a\u542b\u6709\u4e00\u6b21\u6027\u9a8c\u8bc1\u7801\u7684\u77ed\u4fe1\u5230\u7528\u6237\u624b\u673a&#xff0c;\u7528\u6237\u8f93\u5165\u9a8c\u8bc1\u7801\u540e\u9a8c\u8bc1\u624b\u673a\u3002 <\/li>\n<\/ul>\n<h5> 4.1.2.3 \u6570\u636e\u5b58\u50a8 <\/h5>\n<p> \u6ce8\u518c\u4fe1\u606f\u4e2d\u7684\u654f\u611f\u6570\u636e&#xff08;\u5982\u5bc6\u7801&#xff09;\u5e94\u4f7f\u7528\u54c8\u5e0c\u52a0\u76d0\u5b58\u50a8\u3002\u5176\u4ed6\u6570\u636e\u5982\u90ae\u7bb1\u548c\u624b\u673a\u53f7\u7801&#xff0c;\u53ef\u4ee5\u6839\u636e\u9700\u8981\u8003\u8651\u662f\u5426\u52a0\u5bc6\u3002 <\/p>\n<h4> 4.1.3 \u5b89\u5168\u6027\u8003\u8651&#xff1a;\u5bc6\u7801\u52a0\u5bc6\u4e0e\u9a8c\u8bc1 <\/h4>\n<p> \u5bc6\u7801\u7684\u52a0\u5bc6\u662f\u4fdd\u62a4\u7528\u6237\u4fe1\u606f\u5b89\u5168\u7684\u91cd\u8981\u73af\u8282\u3002\u4f7f\u7528\u4e00\u79cd\u6162\u54c8\u5e0c\u51fd\u6570&#xff08;\u5982bcrypt&#xff09;\u53ef\u4ee5\u589e\u52a0\u7834\u89e3\u5bc6\u7801\u7684\u96be\u5ea6\u3002\u8fd9\u79cd\u51fd\u6570\u8bbe\u8ba1\u7684\u521d\u8877\u5c31\u662f\u4e3a\u4e86\u5728\u9a8c\u8bc1\u5bc6\u7801\u65f6\u6d88\u8017\u8f83\u591a\u7684\u8ba1\u7b97\u8d44\u6e90&#xff0c;\u4ece\u800c\u51cf\u6162\u66b4\u529b\u7834\u89e3\u7684\u901f\u5ea6\u3002 <\/p>\n<h5> 4.1.3.1 \u5bc6\u7801\u54c8\u5e0c <\/h5>\n<p> \u4f8b\u5982&#xff0c;\u5f53\u7528\u6237\u6ce8\u518c\u6216\u66f4\u6539\u5bc6\u7801\u65f6&#xff0c;\u7cfb\u7edf\u53ef\u4ee5\u6267\u884c\u4ee5\u4e0b\u6b65\u9aa4&#xff1a; <\/p>\n<p>import bcrypt<\/p>\n<p>def hash_password(plaintext_password):<br \/>\n    # \u5c06\u5bc6\u7801\u8f6c\u6362\u4e3a\u5b57\u8282\u4e32&#xff0c;\u7136\u540e\u751f\u6210\u76d0\u503c<br \/>\n    salt &#061; bcrypt.gensalt()<br \/>\n    # \u5bf9\u5bc6\u7801\u8fdb\u884c\u54c8\u5e0c<br \/>\n    hashed_password &#061; bcrypt.hashpw(plaintext_password.encode(&#039;utf-8&#039;), salt)<br \/>\n    return hashed_password<\/p>\n<p> \u5728\u9a8c\u8bc1\u5bc6\u7801\u65f6&#xff1a; <\/p>\n<p>def check_password(plaintext_password, hashed_password):<br \/>\n    # \u5bf9\u7528\u6237\u8f93\u5165\u7684\u660e\u6587\u5bc6\u7801\u8fdb\u884c\u54c8\u5e0c<br \/>\n    return bcrypt.checkpw(plaintext_password.encode(&#039;utf-8&#039;), hashed_password)<\/p>\n<p> \u8fd9\u4e9b\u6b65\u9aa4\u786e\u4fdd\u5bc6\u7801\u88ab\u5b89\u5168\u5730\u5904\u7406&#xff0c;\u5373\u4f7f\u6570\u636e\u6cc4\u9732&#xff0c;\u653b\u51fb\u8005\u4e5f\u96be\u4ee5\u76f4\u63a5\u83b7\u53d6\u5bc6\u7801\u3002 <\/p>\n<h3> 4.2 \u804a\u5929\u7cfb\u7edf\u7684\u8bbe\u8ba1\u8981\u70b9 <\/h3>\n<h4> 4.2.1 \u804a\u5929\u6d88\u606f\u7684\u5b9e\u65f6\u4f20\u8f93 <\/h4>\n<p> \u804a\u5929\u7cfb\u7edf\u9700\u8981\u5b9e\u65f6\u6027&#xff0c;\u5373\u6d88\u606f\u4ece\u53d1\u9001\u65b9\u53d1\u9001\u51fa\u53bb\u540e&#xff0c;\u5e94\u5c3d\u53ef\u80fd\u5feb\u5730\u4f20\u9012\u7ed9\u63a5\u6536\u65b9\u3002\u8fd9\u901a\u5e38\u6d89\u53ca\u6d88\u606f\u961f\u5217\u3001\u63a8\u9001\u901a\u77e5\u673a\u5236\u548cWebSockets\u7b49\u6280\u672f\u3002 <\/p>\n<h5> 4.2.1.1 \u6d88\u606f\u961f\u5217 <\/h5>\n<p> \u6d88\u606f\u961f\u5217&#xff08;\u5982RabbitMQ\u3001Kafka&#xff09;\u53ef\u4ee5\u6709\u6548\u7ba1\u7406\u6d88\u606f\u7684\u4f20\u8f93\u3002\u6d88\u606f\u53d1\u9001\u65b9\u5c06\u6d88\u606f\u53d1\u5e03\u5230\u961f\u5217\u4e2d&#xff0c;\u6d88\u606f\u63a5\u6536\u65b9\u8ba2\u9605\u961f\u5217\u5e76\u5904\u7406\u6d88\u606f\u3002 <\/p>\n<p>graph LR<br \/>\nA[\u5ba2\u6237\u7aef] &#8211;&gt;|\u53d1\u9001\u6d88\u606f| B[\u6d88\u606f\u961f\u5217]<br \/>\nB &#8211;&gt;|\u4f20\u9012\u6d88\u606f| C[\u670d\u52a1\u5668]<br \/>\nC &#8211;&gt;|\u63a5\u6536\u6d88\u606f| D[\u5ba2\u6237\u7aef]<\/p>\n<h5> 4.2.1.2 WebSockets <\/h5>\n<p> \u5bf9\u4e8e\u9700\u8981\u53cc\u5411\u5b9e\u65f6\u901a\u4fe1\u7684\u5e94\u7528\u573a\u666f&#xff0c;WebSockets\u63d0\u4f9b\u4e86\u4e00\u4e2a\u57fa\u4e8eTCP\u7684\u5168\u53cc\u5de5\u901a\u4fe1\u901a\u9053\u3002 <\/p>\n<p>\/\/ \u5efa\u7acbWebSocket\u8fde\u63a5<br \/>\nvar socket &#061; new WebSocket(&#039;wss:\/\/example.com\/ws&#039;);<\/p>\n<p>\/\/ \u8fde\u63a5\u6253\u5f00\u4e8b\u4ef6<br \/>\nsocket.onopen &#061; function (event) {<br \/>\n    socket.send(&#039;Hello Server!&#039;);<br \/>\n};<\/p>\n<p>\/\/ \u63a5\u6536\u5230\u6d88\u606f\u4e8b\u4ef6<br \/>\nsocket.onmessage &#061; function (event) {<br \/>\n    console.log(&#039;Message from server &#039;, event.data);<br \/>\n};<\/p>\n<h4> 4.2.2 \u804a\u5929\u8bb0\u5f55\u7684\u4fdd\u5b58\u4e0e\u67e5\u8be2 <\/h4>\n<p> \u804a\u5929\u8bb0\u5f55\u7684\u4fdd\u5b58\u5bf9\u7528\u6237\u4f53\u9a8c\u81f3\u5173\u91cd\u8981&#xff0c;\u540c\u65f6\u8fd8\u9700\u8981\u63d0\u4f9b\u65b9\u4fbf\u7684\u8bb0\u5f55\u67e5\u8be2\u529f\u80fd\u3002 <\/p>\n<h5> 4.2.2.1 \u5b58\u50a8\u7b56\u7565 <\/h5>\n<p> \u804a\u5929\u8bb0\u5f55\u53ef\u4ee5\u5b58\u50a8\u5728\u6570\u636e\u5e93\u4e2d&#xff0c;\u6bcf\u6b21\u6d88\u606f\u4f20\u9012\u65f6&#xff0c;\u5c06\u6d88\u606f\u5199\u5165\u6570\u636e\u5e93\u3002\u4e3a\u4e86\u63d0\u9ad8\u67e5\u8be2\u6548\u7387&#xff0c;\u53ef\u4ee5\u5efa\u7acb\u7d22\u5f15\u3002 <\/p>\n<p>CREATE TABLE chat_messages (<br \/>\n    id INT AUTO_INCREMENT PRIMARY KEY,<br \/>\n    sender_id INT NOT NULL,<br \/>\n    receiver_id INT NOT NULL,<br \/>\n    message TEXT NOT NULL,<br \/>\n    send_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,<br \/>\n    INDEX idx_sender_receiver (sender_id, receiver_id)<br \/>\n);<\/p>\n<h4> 4.2.3 \u7528\u6237\u72b6\u6001\u7684\u5b9e\u65f6\u66f4\u65b0\u4e0e\u540c\u6b65 <\/h4>\n<p> \u7528\u6237\u72b6\u6001\u7684\u66f4\u65b0&#xff08;\u5982\u5728\u7ebf\u3001\u79bb\u7ebf&#xff09;\u9700\u8981\u5feb\u901f\u540c\u6b65\u7ed9\u6240\u6709\u5728\u7ebf\u7528\u6237\u3002 <\/p>\n<h5> 4.2.3.1 \u5728\u7ebf\u72b6\u6001\u7684\u8ddf\u8e2a <\/h5>\n<p> \u53ef\u4ee5\u4f7f\u7528\u6570\u636e\u5e93\u6216\u7f13\u5b58\u7cfb\u7edf\u6765\u8ddf\u8e2a\u7528\u6237\u7684\u5728\u7ebf\u72b6\u6001\u3002 <\/p>\n<p># \u66f4\u65b0\u7528\u6237\u5728\u7ebf\u72b6\u6001<br \/>\ndef update_user_status(user_id, status):<br \/>\n    cache.set(f&#034;online_{user_id}&#034;, status, timeout&#061;300)  # 300\u79d2\u540e\u81ea\u52a8\u8fc7\u671f<\/p>\n<p># \u68c0\u67e5\u7528\u6237\u662f\u5426\u5728\u7ebf<br \/>\ndef is_user_online(user_id):<br \/>\n    return cache.get(f&#034;online_{user_id}&#034;) &#061;&#061; &#034;online&#034;<\/p>\n<h3> 4.3 \u7cfb\u7edf\u96c6\u6210\u4e0e\u6d4b\u8bd5 <\/h3>\n<h4> 4.3.1 \u5ba2\u6237\u7aef\u4e0e\u670d\u52a1\u5668\u7684\u6574\u5408\u6d4b\u8bd5 <\/h4>\n<p> \u6574\u5408\u6d4b\u8bd5\u662f\u786e\u4fdd\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u5668\u7aef\u80fd\u591f\u6b63\u786e\u4ea4\u4e92\u7684\u5173\u952e\u73af\u8282\u3002 <\/p>\n<h5> 4.3.1.1 \u6d4b\u8bd5\u6d41\u7a0b <\/h5>\n<p> \u6574\u5408\u6d4b\u8bd5\u5e94\u5305\u62ec\u4ee5\u4e0b\u51e0\u4e2a\u6b65\u9aa4&#xff1a; <\/p>\n<li>  \u63a5\u53e3\u6d4b\u8bd5  &#xff1a;\u6d4b\u8bd5\u5ba2\u6237\u7aef\u4e0e\u670d\u52a1\u5668\u7aef\u4e4b\u95f4\u7684API\u8c03\u7528\u662f\u5426\u6b63\u786e\u3002 <\/li>\n<li>  \u6027\u80fd\u6d4b\u8bd5  &#xff1a;\u8bc4\u4f30\u5728\u9ad8\u8d1f\u8f7d\u60c5\u51b5\u4e0b\u7684\u7cfb\u7edf\u8868\u73b0\u3002 <\/li>\n<li>  \u7528\u6237\u4f53\u9a8c\u6d4b\u8bd5  &#xff1a;\u7531\u6d4b\u8bd5\u8005\u626e\u6f14\u6700\u7ec8\u7528\u6237&#xff0c;\u68c0\u67e5\u7cfb\u7edf\u7684\u6613\u7528\u6027\u3002 <\/li>\n<h4> 4.3.2 \u6027\u80fd\u8bc4\u4f30\u548c\u74f6\u9888\u5206\u6790 <\/h4>\n<p> \u6027\u80fd\u8bc4\u4f30\u548c\u74f6\u9888\u5206\u6790\u80fd\u591f\u63ed\u793a\u7cfb\u7edf\u7684\u6027\u80fd\u9650\u5236\u548c\u6f5c\u5728\u7684\u6027\u80fd\u95ee\u9898\u3002 <\/p>\n<h5> 4.3.2.1 \u6027\u80fd\u8bc4\u4f30\u5de5\u5177 <\/h5>\n<p> \u6027\u80fd\u8bc4\u4f30\u5de5\u5177\u5982JMeter\u3001LoadRunner\u53ef\u4ee5\u6a21\u62df\u5927\u91cf\u7528\u6237\u5bf9\u7cfb\u7edf\u8fdb\u884c\u538b\u529b\u6d4b\u8bd5\u3002 <\/p>\n<p>jmeter -n -t login_test.jmx -l log.jtl<\/p>\n<h4> 4.3.3 \u7528\u6237\u4f53\u9a8c\u4f18\u5316\u4e0e\u53cd\u9988\u6536\u96c6 <\/h4>\n<p> \u7528\u6237\u4f53\u9a8c\u4f18\u5316\u662f\u4e00\u4e2a\u4e0d\u65ad\u8fed\u4ee3\u7684\u8fc7\u7a0b&#xff0c;\u9700\u8981\u7528\u6237\u7684\u53cd\u9988\u4f5c\u4e3a\u4f9d\u636e\u3002 <\/p>\n<h5> 4.3.3.1 \u53cd\u9988\u6536\u96c6\u673a\u5236 <\/h5>\n<p> \u53ef\u4ee5\u901a\u8fc7\u8c03\u67e5\u95ee\u5377\u3001\u7528\u6237\u8bbf\u8c08\u3001\u6570\u636e\u5206\u6790\u7b49\u65b9\u5f0f\u6536\u96c6\u7528\u6237\u53cd\u9988\u3002 <\/p>\n<p># \u7528\u6237\u53cd\u9988\u6570\u636e\u6536\u96c6\u51fd\u6570<br \/>\ndef collect_feedback(user_id, feedback):<br \/>\n    feedback_data &#061; {<br \/>\n        &#034;user_id&#034;: user_id,<br \/>\n        &#034;feedback&#034;: feedback,<br \/>\n        &#034;timestamp&#034;: datetime.now()<br \/>\n    }<br \/>\n    # \u5c06\u53cd\u9988\u6570\u636e\u5b58\u50a8\u5230\u6570\u636e\u5e93<br \/>\n    database.insert(&#039;feedback&#039;, feedback_data)<\/p>\n<p> \u603b\u7ed3\u672c\u7ae0\u8282\u5185\u5bb9&#xff0c;\u6211\u4eec\u8be6\u7ec6\u63a2\u8ba8\u4e86\u767b\u5f55\u3001\u6ce8\u518c\u3001\u804a\u5929\u7cfb\u7edf\u7684\u8bbe\u8ba1\u4e0e\u5b9e\u73b0\u65b9\u6cd5\u3002\u4ece\u7528\u6237\u8eab\u4efd\u9a8c\u8bc1\u673a\u5236\u3001\u804a\u5929\u7cfb\u7edf\u7684\u5b9e\u65f6\u4f20\u8f93\u4e0e\u72b6\u6001\u540c\u6b65&#xff0c;\u5230\u6574\u5408\u6d4b\u8bd5\u548c\u7528\u6237\u4f53\u9a8c\u4f18\u5316&#xff0c;\u6bcf\u4e00\u6b65\u90fd\u5173\u952e\u4e8e\u4fdd\u969c\u7cfb\u7edf\u7684\u5065\u58ee\u6027\u548c\u7528\u6237\u7684\u6ee1\u610f\u5ea6\u3002\u8fd9\u4e9b\u7cfb\u7edf\u7684\u5b9e\u73b0\u9700\u8981\u5bf9\u5b89\u5168\u6027\u548c\u5b9e\u65f6\u6027\u6709\u6df1\u5165\u7684\u7406\u89e3\u548c\u7cbe\u786e\u7684\u6280\u672f\u8fd0\u7528\u3002 <\/p>\n<h2> 5. \u670d\u52a1\u5668\u4e0e\u5ba2\u6237\u7aef\u6570\u636e\u5e93\u4ea4\u4e92 <\/h2>\n<p> \u5728\u73b0\u4ee3\u7f51\u7edc\u5e94\u7528\u4e2d&#xff0c;\u6570\u636e\u5e93\u662f\u4e00\u4e2a\u4e0d\u53ef\u6216\u7f3a\u7684\u7ec4\u6210\u90e8\u5206&#xff0c;\u5b83\u8d1f\u8d23\u5b58\u50a8\u548c\u7ba1\u7406\u5e94\u7528\u6240\u9700\u7684\u6240\u6709\u6570\u636e\u3002\u5728\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u5668\u4e4b\u95f4\u8fdb\u884c\u6709\u6548\u7684\u6570\u636e\u4ea4\u4e92\u662f\u6784\u5efa\u9ad8\u6548\u3001\u7a33\u5b9a\u5e94\u7528\u7684\u5173\u952e\u3002\u672c\u7ae0\u8282\u5c06\u63a2\u8ba8\u670d\u52a1\u5668\u4e0e\u5ba2\u6237\u7aef\u5982\u4f55\u901a\u8fc7\u6570\u636e\u5e93\u8fdb\u884c\u4ea4\u4e92&#xff0c;\u6db5\u76d6\u6570\u636e\u5e93\u9009\u62e9\u3001\u670d\u52a1\u5668\u7aef\u64cd\u4f5c\u548c\u5ba2\u6237\u7aef\u4ea4\u4e92\u5b9e\u8df5\u7684\u5404\u4e2a\u65b9\u9762\u3002 <\/p>\n<h3> 5.1 \u6570\u636e\u5e93\u4e0e\u7f51\u7edc\u5e94\u7528\u7684\u5173\u7cfb <\/h3>\n<p> \u6570\u636e\u5e93\u4e0d\u4ec5\u5b58\u50a8\u7740\u7f51\u7edc\u5e94\u7528\u7684\u6570\u636e&#xff0c;\u8fd8\u8d1f\u8d23\u5904\u7406\u6570\u636e\u7684\u8bfb\u5199\u8bf7\u6c42&#xff0c;\u662f\u7f51\u7edc\u5e94\u7528\u540e\u7aef\u7684\u57fa\u77f3\u3002 <\/p>\n<h4> 5.1.1 \u6570\u636e\u5e93\u5728\u7cfb\u7edf\u4e2d\u7684\u4f5c\u7528\u548c\u91cd\u8981\u6027 <\/h4>\n<p> \u6570\u636e\u5e93\u7cfb\u7edf\u4e3a\u7f51\u7edc\u5e94\u7528\u63d0\u4f9b\u4e86\u4e00\u4e2a\u7ed3\u6784\u5316\u5b58\u50a8\u6570\u636e\u7684\u65b9\u5f0f\u3002\u8fd9\u4e9b\u6570\u636e\u5305\u62ec\u7528\u6237\u4fe1\u606f\u3001\u5185\u5bb9\u3001\u65e5\u5fd7\u8bb0\u5f55\u3001\u914d\u7f6e\u6570\u636e\u7b49\u3002\u5728\u5904\u7406\u5927\u91cf\u6570\u636e\u548c\u9700\u8981\u5feb\u901f\u68c0\u7d22\u6570\u636e\u7684\u573a\u666f\u4e0b&#xff0c;\u6570\u636e\u5e93\u7684\u4f5c\u7528\u5c24\u4e3a\u5173\u952e\u3002 <\/p>\n<p> \u6570\u636e\u5e93\u8fd8\u63d0\u4f9b\u4e86\u6570\u636e\u4e00\u81f4\u6027\u548c\u5b8c\u6574\u6027\u4fdd\u969c\u3002\u901a\u8fc7\u4e8b\u52a1\u5904\u7406\u3001\u9501\u673a\u5236\u3001\u5e76\u53d1\u63a7\u5236\u7b49\u6280\u672f&#xff0c;\u6570\u636e\u5e93\u80fd\u591f\u4fdd\u8bc1\u5728\u591a\u7528\u6237\u73af\u5883\u4e0b\u6570\u636e\u7684\u5b89\u5168\u6027\u548c\u51c6\u786e\u6027\u3002 <\/p>\n<h4> 5.1.2 \u6570\u636e\u5e93\u8bbf\u95ee\u6280\u672f\u7684\u9009\u62e9\u4e0e\u5bf9\u6bd4 <\/h4>\n<p> \u6570\u636e\u5e93\u8bbf\u95ee\u6280\u672f\u7684\u9009\u62e9\u901a\u5e38\u7531\u591a\u79cd\u56e0\u7d20\u51b3\u5b9a&#xff0c;\u5305\u62ec\u4f46\u4e0d\u9650\u4e8e\u5e94\u7528\u9700\u6c42\u3001\u6027\u80fd\u8003\u8651\u3001\u5f00\u53d1\u4fbf\u6377\u6027\u7b49\u3002\u4e3b\u8981\u7684\u6570\u636e\u5e93\u8bbf\u95ee\u6280\u672f\u5305\u62ec&#xff1a; <\/p>\n<ul>\n<li> \u539f\u751fAPI&#xff1a;\u5982MySQL C API&#xff0c;\u63d0\u4f9b\u4e86\u6700\u5e95\u5c42\u7684\u6570\u636e\u5e93\u8bbf\u95ee\u80fd\u529b&#xff0c;\u53ef\u4ee5\u5b9e\u73b0\u9ad8\u5ea6\u5b9a\u5236\u5316&#xff0c;\u4f46\u5f00\u53d1\u590d\u6742\u5ea6\u9ad8\u3002 <\/li>\n<li> ODBC\/JDBC&#xff1a;\u63d0\u4f9b\u4e86\u4e00\u79cd\u901a\u7528\u7684\u6570\u636e\u5e93\u8bbf\u95ee\u65b9\u5f0f&#xff0c;\u53ef\u4ee5\u8de8\u5e73\u53f0\u3001\u8de8\u6570\u636e\u5e93&#xff0c;\u4f46\u6027\u80fd\u4e0a\u53ef\u80fd\u4e0d\u662f\u6700\u4f18\u3002 <\/li>\n<li> ORM&#xff08;\u5bf9\u8c61\u5173\u7cfb\u6620\u5c04&#xff09;&#xff1a;\u5982Hibernate\u3001Entity Framework&#xff0c;\u62bd\u8c61\u4e86\u6570\u636e\u5e93\u8bbf\u95ee\u7ec6\u8282&#xff0c;\u4f7f\u5f97\u5f00\u53d1\u8005\u80fd\u4ee5\u9762\u5411\u5bf9\u8c61\u7684\u65b9\u5f0f\u64cd\u4f5c\u6570\u636e\u5e93&#xff0c;\u6781\u5927\u5730\u63d0\u9ad8\u4e86\u5f00\u53d1\u6548\u7387&#xff0c;\u4f46\u53ef\u80fd\u4f1a\u6709\u6027\u80fd\u635f\u8017\u3002 <\/li>\n<\/ul>\n<h3> 5.2 \u670d\u52a1\u5668\u7aef\u6570\u636e\u5e93\u64cd\u4f5c\u5b9e\u73b0 <\/h3>\n<p> \u670d\u52a1\u5668\u7aef\u7684\u6570\u636e\u5e93\u64cd\u4f5c\u4e3b\u8981\u8d1f\u8d23\u5904\u7406\u4e1a\u52a1\u903b\u8f91\u4e2d\u5bf9\u6570\u636e\u7684\u8bf7\u6c42&#xff0c;\u8fd9\u4e00\u90e8\u5206\u7684\u6027\u80fd\u76f4\u63a5\u5f71\u54cd\u6574\u4e2a\u5e94\u7528\u7684\u6548\u7387\u3002 <\/p>\n<h4> 5.2.1 \u6570\u636e\u5e93\u8fde\u63a5\u6c60\u7684\u5e94\u7528 <\/h4>\n<p> \u6570\u636e\u5e93\u8fde\u63a5\u6c60\u662f\u4e00\u4e2a\u7528\u4e8e\u7ba1\u7406\u6570\u636e\u5e93\u8fde\u63a5\u7684\u7f13\u5b58\u6c60&#xff0c;\u5b83\u53ef\u4ee5\u663e\u8457\u63d0\u9ad8\u5e94\u7528\u6027\u80fd&#xff0c;\u7279\u522b\u662f\u5728\u9ad8\u5e76\u53d1\u73af\u5883\u4e0b\u3002\u8fde\u63a5\u6c60\u7684\u4e3b\u8981\u4f18\u52bf\u5305\u62ec&#xff1a; <\/p>\n<ul>\n<li> \u51cf\u5c11\u8fde\u63a5\u5f00\u9500&#xff1a;\u901a\u8fc7\u590d\u7528\u5df2\u7ecf\u5efa\u7acb\u7684\u6570\u636e\u5e93\u8fde\u63a5&#xff0c;\u907f\u514d\u4e86\u9891\u7e41\u7684\u8fde\u63a5\u521b\u5efa\u548c\u9500\u6bc1\u5e26\u6765\u7684\u6027\u80fd\u5f00\u9500\u3002 <\/li>\n<li> \u7a33\u5b9a\u7684\u6027\u80fd\u8868\u73b0&#xff1a;\u8fde\u63a5\u6c60\u53ef\u4ee5\u5e73\u8861\u8bf7\u6c42\u8d1f\u8f7d&#xff0c;\u9632\u6b62\u6570\u636e\u5e93\u8fde\u63a5\u6570\u8fc7\u591a\u5bfc\u81f4\u7684\u670d\u52a1\u5668\u5d29\u6e83\u3002 <\/li>\n<li> \u63d0\u4f9b\u914d\u7f6e\u7075\u6d3b\u6027&#xff1a;\u53ef\u4ee5\u914d\u7f6e\u8fde\u63a5\u6c60\u7684\u5927\u5c0f\u3001\u8d85\u65f6\u65f6\u95f4\u3001\u8fde\u63a5\u6709\u6548\u6027\u68c0\u6d4b\u7b49\u53c2\u6570&#xff0c;\u4ee5\u9002\u5e94\u4e0d\u540c\u7684\u4f7f\u7528\u573a\u666f\u3002 <\/li>\n<\/ul>\n<h4> 5.2.2 SQL\u8bed\u53e5\u7684\u6267\u884c\u4e0e\u9519\u8bef\u5904\u7406 <\/h4>\n<p> \u6267\u884cSQL\u8bed\u53e5\u662f\u4e0e\u6570\u636e\u5e93\u4ea4\u4e92\u7684\u57fa\u7840&#xff0c;\u6b63\u786e\u5904\u7406SQL\u8bed\u53e5\u7684\u6267\u884c\u7ed3\u679c\u548c\u5f02\u5e38\u662f\u4fdd\u8bc1\u5e94\u7528\u7a33\u5b9a\u8fd0\u884c\u7684\u5173\u952e\u3002\u57fa\u672c\u7684\u6267\u884c\u6d41\u7a0b\u5305\u62ec&#xff1a; <\/p>\n<li> \u51c6\u5907SQL\u8bed\u53e5&#xff0c;\u5e76\u6839\u636e\u6570\u636e\u5e93\u7684\u5177\u4f53\u7c7b\u578b\u9009\u62e9\u5408\u9002\u7684API\u8fdb\u884c\u6267\u884c\u3002 <\/li>\n<li> \u5904\u7406SQL\u6267\u884c\u7684\u7ed3\u679c&#xff0c;\u4f8b\u5982\u8bfb\u53d6\u6570\u636e\u3001\u8ba1\u7b97\u5f71\u54cd\u7684\u884c\u6570\u7b49\u3002 <\/li>\n<li> \u5bf9\u4e8e\u6267\u884c\u5931\u8d25\u7684\u60c5\u51b5&#xff0c;\u6355\u83b7\u5e76\u5904\u7406\u5f02\u5e38&#xff0c;\u7ed9\u51fa\u660e\u786e\u7684\u9519\u8bef\u4fe1\u606f\u3002 <\/li>\n<p>try {<br \/>\n    \/\/ \u521b\u5efa\u4e00\u4e2a\u6570\u636e\u5e93\u8fde\u63a5<br \/>\n    Connection conn &#061; pool.getConnection();<br \/>\n    \/\/ \u521b\u5efa\u4e00\u4e2a\u8bed\u53e5\u5bf9\u8c61<br \/>\n    Statement stmt &#061; conn.createStatement();<br \/>\n    \/\/ \u6267\u884c\u67e5\u8be2<br \/>\n    ResultSet rs &#061; stmt.executeQuery(&#034;SELECT * FROM users WHERE id &#061; 1&#034;);<br \/>\n    while (rs.next()) {<br \/>\n        \/\/ \u5904\u7406\u7ed3\u679c\u96c6<br \/>\n        System.out.println(rs.getInt(&#034;id&#034;) &#043; &#034;\\\\t&#034; &#043; rs.getString(&#034;name&#034;));<br \/>\n    }<br \/>\n    \/\/ \u5173\u95ed\u8fde\u63a5\u548c\u8bed\u53e5\u5bf9\u8c61<br \/>\n    rs.close();<br \/>\n    stmt.close();<br \/>\n    conn.close();<br \/>\n} catch (SQLException e) {<br \/>\n    \/\/ \u6253\u5370SQL\u5f02\u5e38\u4fe1\u606f<br \/>\n    e.printStackTrace();<br \/>\n}<\/p>\n<h4> 5.2.3 \u6570\u636e\u5e93\u4e8b\u52a1\u7684\u7ba1\u7406\u4e0e\u4f18\u5316 <\/h4>\n<p> \u4e8b\u52a1\u662f\u6570\u636e\u5e93\u64cd\u4f5c\u7684\u57fa\u672c\u5355\u4f4d&#xff0c;\u5b83\u4fdd\u8bc1\u4e86\u4e00\u7ec4\u64cd\u4f5c\u8981\u4e48\u5168\u90e8\u6210\u529f&#xff0c;\u8981\u4e48\u5168\u90e8\u5931\u8d25\u3002\u5bf9\u4e8e\u6d89\u53ca\u591a\u4e2a\u6b65\u9aa4\u7684\u64cd\u4f5c&#xff0c;\u4e8b\u52a1\u663e\u5f97\u5c24\u4e3a\u91cd\u8981\u3002\u4e8b\u52a1\u7ba1\u7406\u7684\u5173\u952e\u6982\u5ff5\u5305\u62ec&#xff1a; <\/p>\n<ul>\n<li> ACID\u5c5e\u6027&#xff1a;\u539f\u5b50\u6027&#xff08;Atomicity&#xff09;\u3001\u4e00\u81f4\u6027&#xff08;Consistency&#xff09;\u3001\u9694\u79bb\u6027&#xff08;Isolation&#xff09;\u3001\u6301\u4e45\u6027&#xff08;Durability&#xff09;\u662f\u4e8b\u52a1\u7684\u57fa\u672c\u7279\u6027\u3002 <\/li>\n<li> \u4e8b\u52a1\u9694\u79bb\u7ea7\u522b&#xff1a;\u4e0d\u540c\u7684\u9694\u79bb\u7ea7\u522b\u53ef\u4ee5\u89e3\u51b3\u5e76\u53d1\u73af\u5883\u4e0b\u7684\u4e0d\u540c\u95ee\u9898&#xff0c;\u4f46\u4e5f\u4f1a\u5e26\u6765\u6027\u80fd\u4e0a\u7684\u727a\u7272\u3002\u5e38\u89c1\u7684\u9694\u79bb\u7ea7\u522b\u5305\u62ec\u8bfb\u672a\u63d0\u4ea4&#xff08;Read Uncommitted&#xff09;\u3001\u8bfb\u63d0\u4ea4&#xff08;Read Committed&#xff09;\u3001\u53ef\u91cd\u590d\u8bfb&#xff08;Repeatable Read&#xff09;\u548c\u4e32\u884c\u5316&#xff08;Serializable&#xff09;\u3002 <\/li>\n<\/ul>\n<h3> 5.3 \u5ba2\u6237\u7aef\u6570\u636e\u5e93\u4ea4\u4e92\u5b9e\u8df5 <\/h3>\n<p> \u5ba2\u6237\u7aef\u6570\u636e\u5e93\u4ea4\u4e92\u5173\u6ce8\u5982\u4f55\u8ba9\u5ba2\u6237\u7aef\u6709\u6548\u5730\u4f7f\u7528\u6570\u636e\u5e93\u6765\u63d0\u5347\u7528\u6237\u4f53\u9a8c&#xff0c;\u8fd9\u5305\u62ec\u672c\u5730\u7f13\u5b58\u7b56\u7565\u3001\u6570\u636e\u540c\u6b65\u4ee5\u53ca\u5b89\u5168\u6027\u7b49\u65b9\u9762\u3002 <\/p>\n<h4> 5.3.1 \u5ba2\u6237\u7aef\u6570\u636e\u7f13\u5b58\u7b56\u7565 <\/h4>\n<p> \u5ba2\u6237\u7aef\u7f13\u5b58\u662f\u51cf\u5c11\u7f51\u7edc\u901a\u4fe1\u548c\u63d0\u5347\u7528\u6237\u4f53\u9a8c\u7684\u91cd\u8981\u624b\u6bb5\u3002\u5408\u7406\u7684\u7f13\u5b58\u7b56\u7565\u53ef\u4ee5\u51cf\u5c11\u5bf9\u670d\u52a1\u5668\u7684\u4e0d\u5fc5\u8981\u8bf7\u6c42&#xff0c;\u51cf\u5c11\u5ef6\u8fdf\u3002 <\/p>\n<ul>\n<li> \u7f13\u5b58\u4f4d\u7f6e&#xff1a;\u5ba2\u6237\u7aef\u7f13\u5b58\u53ef\u4ee5\u653e\u5728\u672c\u5730\u6587\u4ef6\u3001\u5185\u5b58\u3001\u6216\u662f\u4f7f\u7528\u66f4\u9ad8\u7ea7\u7684\u672c\u5730\u6570\u636e\u5e93&#xff0c;\u5982SQLite\u3002 <\/li>\n<li> \u7f13\u5b58\u7ea7\u522b&#xff1a;\u7f13\u5b58\u53ef\u4ee5\u662f\u5168\u91cf\u7f13\u5b58&#xff0c;\u4e5f\u53ef\u4ee5\u662f\u90e8\u5206\u7f13\u5b58&#xff0c;\u6839\u636e\u9700\u8981\u66f4\u65b0\u7684\u9891\u7387\u548c\u6570\u636e\u7684\u91cd\u8981\u6027\u8fdb\u884c\u9009\u62e9\u3002 <\/li>\n<li> \u7f13\u5b58\u66f4\u65b0\u7b56\u7565&#xff1a;\u5b9a\u65f6\u66f4\u65b0\u3001\u61d2\u52a0\u8f7d\u6216\u4e8b\u4ef6\u89e6\u53d1\u66f4\u65b0&#xff0c;\u90fd\u662f\u5e38\u89c1\u7684\u7f13\u5b58\u66f4\u65b0\u65b9\u5f0f\u3002 <\/li>\n<\/ul>\n<h4> 5.3.2 \u6570\u636e\u540c\u6b65\u4e0e\u51b2\u7a81\u89e3\u51b3\u673a\u5236 <\/h4>\n<p> \u6570\u636e\u540c\u6b65\u662f\u786e\u4fdd\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u5668\u7aef\u6570\u636e\u4e00\u81f4\u6027\u7684\u91cd\u8981\u624b\u6bb5\u3002\u5e38\u89c1\u7684\u540c\u6b65\u7b56\u7565\u6709&#xff1a; <\/p>\n<ul>\n<li> \u62c9\u53d6&#xff08;Pull&#xff09;&#xff1a;\u5ba2\u6237\u7aef\u5b9a\u671f\u6216\u5728\u7279\u5b9a\u6761\u4ef6\u4e0b\u4ece\u670d\u52a1\u5668\u62c9\u53d6\u6700\u65b0\u7684\u6570\u636e\u3002 <\/li>\n<li> \u63a8\u9001&#xff08;Push&#xff09;&#xff1a;\u670d\u52a1\u5668\u4e3b\u52a8\u5c06\u66f4\u65b0\u7684\u6570\u636e\u53d1\u9001\u7ed9\u5ba2\u6237\u7aef\u3002 <\/li>\n<\/ul>\n<p> \u51b2\u7a81\u89e3\u51b3\u673a\u5236\u6d89\u53ca\u5230\u591a\u4e2a\u5ba2\u6237\u7aef\u6216\u5ba2\u6237\u7aef\u4e0e\u670d\u52a1\u5668\u95f4\u7684\u6570\u636e\u540c\u6b65\u65f6&#xff0c;\u5982\u4f55\u5904\u7406\u540c\u4e00\u6570\u636e\u7684\u4e0d\u540c\u7248\u672c&#xff0c;\u4f8b\u5982&#xff1a; <\/p>\n<ul>\n<li> \u65f6\u95f4\u6233&#xff1a;\u6bd4\u8f83\u6570\u636e\u7684\u4fee\u6539\u65f6\u95f4&#xff0c;\u9009\u62e9\u6700\u65b0\u7684\u6570\u636e\u3002 <\/li>\n<li> \u7248\u672c\u53f7&#xff1a;\u5728\u6570\u636e\u4e2d\u589e\u52a0\u7248\u672c\u53f7\u5b57\u6bb5&#xff0c;\u4f7f\u7528\u7248\u672c\u53f7\u6765\u89e3\u51b3\u51b2\u7a81\u3002 <\/li>\n<li> \u4e2d\u5fc3\u670d\u52a1\u5668&#xff1a;\u6240\u6709\u7684\u6570\u636e\u66f4\u65b0\u90fd\u901a\u8fc7\u4e2d\u5fc3\u670d\u52a1\u5668\u8fdb\u884c&#xff0c;\u7531\u670d\u52a1\u5668\u6765\u89e3\u51b3\u51b2\u7a81\u3002 <\/li>\n<\/ul>\n<h4> 5.3.3 \u5ba2\u6237\u7aef\u6570\u636e\u5e93\u7684\u5b89\u5168\u6027\u8003\u8651 <\/h4>\n<p> \u5ba2\u6237\u7aef\u6570\u636e\u5e93\u5b58\u50a8\u7684\u6570\u636e\u5bf9\u7528\u6237\u9690\u79c1\u81f3\u5173\u91cd\u8981&#xff0c;\u56e0\u6b64\u4fdd\u8bc1\u6570\u636e\u7684\u5b89\u5168\u6027\u663e\u5f97\u5c24\u4e3a\u91cd\u8981\u3002\u5b89\u5168\u63aa\u65bd\u5305\u62ec&#xff1a; <\/p>\n<ul>\n<li> \u52a0\u5bc6&#xff1a;\u5bf9\u5b58\u50a8\u5728\u5ba2\u6237\u7aef\u7684\u654f\u611f\u6570\u636e\u8fdb\u884c\u52a0\u5bc6\u3002 <\/li>\n<li> \u8ba4\u8bc1&#xff1a;\u5bf9\u5ba2\u6237\u7aef\u6570\u636e\u5e93\u64cd\u4f5c\u8fdb\u884c\u8eab\u4efd\u9a8c\u8bc1&#xff0c;\u786e\u4fdd\u6570\u636e\u64cd\u4f5c\u7684\u5408\u6cd5\u6027\u548c\u53ef\u8ffd\u6eaf\u6027\u3002 <\/li>\n<li> \u9632\u6ce8\u5165&#xff1a;\u4f7f\u7528\u53c2\u6570\u5316\u67e5\u8be2\u7b49\u624b\u6bb5\u9632\u6b62SQL\u6ce8\u5165\u653b\u51fb\u3002 <\/li>\n<\/ul>\n<p>\/\/ \u4f7f\u7528SQLite\u8fdb\u884c\u5ba2\u6237\u7aef\u6570\u636e\u5e93\u64cd\u4f5c\u793a\u4f8b<br \/>\nconst sqlite3 &#061; require(&#039;sqlite3&#039;).verbose();<br \/>\nconst db &#061; new sqlite3.Database(&#039;.\/my_database.db&#039;);<\/p>\n<p>db.serialize(() &#061;&gt; {<br \/>\n    db.run(&#039;CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY, name TEXT, email TEXT)&#039;);<br \/>\n    db.run(&#034;INSERT INTO users (name, email) VALUES (&#039;John Doe&#039;, &#039;john&#064;example.com&#039;)&#034;);<br \/>\n});<\/p>\n<p>db.each(&#039;SELECT * FROM users&#039;, (err, row) &#061;&gt; {<br \/>\n    if (err) {<br \/>\n        console.error(err.message);<br \/>\n    } else {<br \/>\n        console.log(row.id &#043; &#039; &#039; &#043; row.name);<br \/>\n    }<br \/>\n});<\/p>\n<p>db.close();<\/p>\n<p> \u670d\u52a1\u5668\u4e0e\u5ba2\u6237\u7aef\u7684\u6570\u636e\u5e93\u4ea4\u4e92\u6d89\u53ca\u5230\u8bb8\u591a\u5c42\u9762\u7684\u6280\u672f\u9009\u62e9\u548c\u5b9e\u73b0\u7ec6\u8282&#xff0c;\u4ece\u6570\u636e\u5e93\u7684\u9009\u62e9\u5230\u5177\u4f53\u7684\u6570\u636e\u5e93\u64cd\u4f5c&#xff0c;\u4ece\u6570\u636e\u540c\u6b65\u5230\u6570\u636e\u5b89\u5168&#xff0c;\u90fd\u9700\u8981\u8003\u8651\u5468\u5168\u4ee5\u786e\u4fdd\u5e94\u7528\u7684\u9ad8\u6548\u548c\u5b89\u5168\u3002\u4e0b\u4e00\u7ae0\u8282\u5c06\u805a\u7126\u4e8e\u7f51\u7edc\u6570\u636e\u4f20\u8f93\u7684\u5b89\u5168\u6027&#xff0c;\u63a2\u8ba8\u5982\u4f55\u5728\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u5668\u4e4b\u95f4\u5efa\u7acb\u5b89\u5168\u7684\u6570\u636e\u4f20\u8f93\u673a\u5236\u3002 <\/p>\n<h2> 6. \u7f51\u7edc\u6570\u636e\u4f20\u8f93\u5b89\u5168\u63aa\u65bd <\/h2>\n<h3> 6.1 \u7f51\u7edc\u6570\u636e\u52a0\u5bc6\u6280\u672f <\/h3>\n<p> \u5728\u65e5\u76ca\u589e\u957f\u7684\u7f51\u7edc\u901a\u4fe1\u5b89\u5168\u9700\u6c42\u9762\u524d&#xff0c;\u6570\u636e\u52a0\u5bc6\u6210\u4e3a\u4e86\u4e0d\u53ef\u6216\u7f3a\u7684\u7ec4\u6210\u90e8\u5206\u3002\u901a\u8fc7\u52a0\u5bc6\u6280\u672f&#xff0c;\u6211\u4eec\u80fd\u591f\u786e\u4fdd\u6570\u636e\u5728\u4f20\u8f93\u8fc7\u7a0b\u4e2d\u5373\u4fbf\u88ab\u622a\u83b7&#xff0c;\u4e5f\u65e0\u6cd5\u88ab\u7b2c\u4e09\u65b9\u8f7b\u6613\u89e3\u8bfb\u3002 <\/p>\n<h4> 6.1.1 \u5bf9\u79f0\u52a0\u5bc6\u4e0e\u975e\u5bf9\u79f0\u52a0\u5bc6\u539f\u7406 <\/h4>\n<p> \u5bf9\u79f0\u52a0\u5bc6\u548c\u975e\u5bf9\u79f0\u52a0\u5bc6\u662f\u4e24\u79cd\u5e38\u89c1\u7684\u52a0\u5bc6\u65b9\u5f0f&#xff0c;\u5b83\u4eec\u5728\u5bc6\u94a5\u7684\u4f7f\u7528\u4e0a\u6709\u7740\u672c\u8d28\u7684\u533a\u522b\u3002 <\/p>\n<p>  \u5bf9\u79f0\u52a0\u5bc6  \u4f7f\u7528\u5355\u4e00\u5bc6\u94a5\u5bf9\u6570\u636e\u8fdb\u884c\u52a0\u5bc6\u548c\u89e3\u5bc6\u3002\u8fd9\u610f\u5473\u7740\u5728\u901a\u4fe1\u7684\u4e24\u7aef&#xff0c;\u53cc\u65b9\u5fc5\u987b\u5171\u4eab\u540c\u4e00\u4e2a\u5bc6\u94a5\u3002\u8fd9\u79cd\u65b9\u5f0f\u7684\u7f3a\u70b9\u5728\u4e8e\u5bc6\u94a5\u7684\u5206\u53d1\u548c\u7ba1\u7406\u6bd4\u8f83\u590d\u6742&#xff0c;\u4f46\u5b83\u7684\u4f18\u70b9\u662f\u52a0\u5bc6\u548c\u89e3\u5bc6\u901f\u5ea6\u5feb&#xff0c;\u9002\u5408\u5927\u91cf\u6570\u636e\u7684\u5904\u7406\u3002\u5e38\u89c1\u7684\u5bf9\u79f0\u52a0\u5bc6\u7b97\u6cd5\u6709AES&#xff08;\u9ad8\u7ea7\u52a0\u5bc6\u6807\u51c6&#xff09;\u3001DES&#xff08;\u6570\u636e\u52a0\u5bc6\u6807\u51c6&#xff09;\u7b49\u3002 <\/p>\n<p>  \u975e\u5bf9\u79f0\u52a0\u5bc6  \u4f7f\u7528\u4e00\u5bf9\u5bc6\u94a5&#xff0c;\u5373\u516c\u94a5\u548c\u79c1\u94a5&#xff0c;\u516c\u94a5\u7528\u4e8e\u52a0\u5bc6\u6570\u636e&#xff0c;\u79c1\u94a5\u7528\u4e8e\u89e3\u5bc6\u6570\u636e\u3002\u8fd9\u79cd\u673a\u5236\u7684\u4e00\u4e2a\u5173\u952e\u4f18\u52bf\u662f\u516c\u94a5\u53ef\u4ee5\u516c\u5f00&#xff0c;\u800c\u79c1\u94a5\u4fdd\u6301\u79c1\u5bc6&#xff0c;\u6781\u5927\u5730\u7b80\u5316\u4e86\u5bc6\u94a5\u7684\u5206\u53d1\u95ee\u9898\u3002\u975e\u5bf9\u79f0\u52a0\u5bc6\u9002\u7528\u4e8e\u8eab\u4efd\u9a8c\u8bc1\u3001\u6570\u5b57\u7b7e\u540d\u7b49\u573a\u666f\u3002\u8457\u540d\u7684\u975e\u5bf9\u79f0\u52a0\u5bc6\u7b97\u6cd5\u6709RSA\u3001ECC&#xff08;\u692d\u5706\u66f2\u7ebf\u52a0\u5bc6\u7b97\u6cd5&#xff09;\u7b49\u3002 <\/p>\n<h4> 6.1.2 SSL\/TLS\u534f\u8bae\u7684\u5b9e\u73b0\u4e0e\u5e94\u7528 <\/h4>\n<p> SSL&#xff08;\u5b89\u5168\u5957\u63a5\u5c42&#xff09;\u548cTLS&#xff08;\u4f20\u8f93\u5c42\u5b89\u5168\u6027\u534f\u8bae&#xff09;\u662f\u4e24\u79cd\u5e7f\u6cdb\u4f7f\u7528\u7684\u534f\u8bae&#xff0c;\u7528\u4ee5\u5728\u4e92\u8054\u7f51\u4e0a\u63d0\u4f9b\u6570\u636e\u52a0\u5bc6\u3001\u8eab\u4efd\u9a8c\u8bc1\u548c\u6570\u636e\u5b8c\u6574\u6027\u3002 <\/p>\n<p> SSL\/TLS\u534f\u8bae\u5728\u4f20\u8f93\u5c42\u548c\u5e94\u7528\u5c42\u4e4b\u95f4\u5de5\u4f5c&#xff0c;\u901a\u8fc7\u5efa\u7acb\u5b89\u5168\u8fde\u63a5\u786e\u4fdd\u4f20\u8f93\u6570\u636e\u7684\u673a\u5bc6\u6027\u548c\u5b8c\u6574\u6027\u3002\u901a\u5e38&#xff0c;\u5f53\u6211\u4eec\u5728\u6d4f\u89c8\u5668\u4e2d\u8bbf\u95ee\u4e00\u4e2aHTTPS\u7f51\u7ad9\u65f6&#xff0c;\u6d4f\u89c8\u5668\u548c\u670d\u52a1\u5668\u5c31\u4f1a\u901a\u8fc7SSL\/TLS\u63e1\u624b&#xff0c;\u5efa\u7acb\u8d77\u4e00\u4e2a\u5b89\u5168\u901a\u9053\u3002 <\/p>\n<p> \u5728\u5b9e\u73b0SSL\/TLS\u65f6&#xff0c;\u670d\u52a1\u5668\u4f1a\u62e5\u6709\u4e00\u4e2a\u7531\u8bc1\u4e66\u9881\u53d1\u673a\u6784&#xff08;CA&#xff09;\u7b7e\u53d1\u7684\u6570\u5b57\u8bc1\u4e66\u3002\u8fd9\u4e2a\u8bc1\u4e66\u5305\u542b\u4e86\u670d\u52a1\u5668\u7684\u516c\u94a5&#xff0c;\u5ba2\u6237\u7aef\u53ef\u4ee5\u4f7f\u7528\u8fd9\u4e2a\u516c\u94a5\u5bf9\u6570\u636e\u8fdb\u884c\u52a0\u5bc6\u3002\u975e\u5bf9\u79f0\u52a0\u5bc6\u4f7f\u5f97\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u5668\u4e4b\u95f4\u7684\u9996\u6b21\u901a\u4fe1\u53d8\u5f97\u5b89\u5168&#xff0c;\u968f\u540e\u53cc\u65b9\u53ef\u4ee5\u534f\u5546\u51fa\u4e00\u4e2a\u5bf9\u79f0\u5bc6\u94a5\u7528\u4e8e\u540e\u7eed\u7684\u6570\u636e\u4f20\u8f93\u3002 <\/p>\n<h3> 6.2 \u5b89\u5168\u8ba4\u8bc1\u673a\u5236 <\/h3>\n<p> \u4e3a\u4e86\u4fdd\u8bc1\u901a\u4fe1\u53cc\u65b9\u7684\u8eab\u4efd\u771f\u5b9e\u6027&#xff0c;\u8ba4\u8bc1\u673a\u5236\u626e\u6f14\u4e86\u91cd\u8981\u89d2\u8272\u3002 <\/p>\n<h4> 6.2.1 \u57fa\u4e8e\u8bc1\u4e66\u7684\u8ba4\u8bc1\u8fc7\u7a0b <\/h4>\n<p> \u57fa\u4e8e\u8bc1\u4e66\u7684\u8ba4\u8bc1\u8fc7\u7a0b\u6d89\u53ca\u7b2c\u4e09\u65b9\u673a\u6784\u2014\u2014\u8ba4\u8bc1\u4e2d\u5fc3&#xff08;CA&#xff09;&#xff0c;CA\u7684\u4e3b\u8981\u804c\u8d23\u662f\u53d1\u653e\u548c\u7ba1\u7406\u6570\u5b57\u8bc1\u4e66\u3002\u5f53\u4e00\u4e2a\u670d\u52a1\u5668\u5e0c\u671b\u88ab\u8bc6\u522b\u4e3a\u5408\u6cd5\u670d\u52a1\u5668\u65f6&#xff0c;\u5b83\u4f1a\u5411CA\u7533\u8bf7\u4e00\u4e2a\u6570\u5b57\u8bc1\u4e66\u3002\u8bc1\u4e66\u4e2d\u5305\u542b\u670d\u52a1\u5668\u7684\u516c\u94a5&#xff0c;\u4ee5\u53caCA\u7684\u7b7e\u540d\u4fe1\u606f\u3002 <\/p>\n<p> \u5f53\u5ba2\u6237\u7aef\u4e0e\u670d\u52a1\u5668\u5efa\u7acb\u8fde\u63a5\u65f6&#xff0c;\u670d\u52a1\u5668\u4f1a\u63d0\u4f9b\u5b83\u7684\u6570\u5b57\u8bc1\u4e66\u3002\u5ba2\u6237\u7aef\u901a\u8fc7\u9a8c\u8bc1CA\u7684\u7b7e\u540d&#xff0c;\u53ef\u4ee5\u786e\u8ba4\u8bc1\u4e66\u7684\u771f\u5b9e\u6027\u4ee5\u53ca\u670d\u52a1\u5668\u7684\u8eab\u4efd\u3002\u8fd9\u4e2a\u8fc7\u7a0b\u4fdd\u8bc1\u4e86\u5ba2\u6237\u7aef\u4e0e\u5408\u6cd5\u670d\u52a1\u5668\u4e4b\u95f4\u7684\u901a\u4fe1\u4e0d\u4f1a\u88ab\u5192\u5145\u3002 <\/p>\n<h4> 6.2.2 \u8ba4\u8bc1\u4e2d\u5fc3(CA)\u7684\u5de5\u4f5c\u539f\u7406 <\/h4>\n<p> \u8ba4\u8bc1\u4e2d\u5fc3\u7684\u6838\u5fc3\u662f\u7ef4\u62a4\u4e00\u4e2a\u53ef\u4fe1\u7684\u516c\u5171\u5bc6\u94a5\u57fa\u7840\u8bbe\u65bd&#xff08;PKI&#xff09;&#xff0c;\u5176\u4e2d\u5305\u62ec\u8bc1\u4e66\u7684\u7b7e\u53d1\u3001\u64a4\u9500\u548c\u66f4\u65b0\u3002 <\/p>\n<ul>\n<li>  \u7b7e\u53d1  &#xff1a;\u5f53\u4e00\u4e2a\u7528\u6237&#xff08;\u6216\u670d\u52a1\u5668&#xff09;\u5411CA\u63d0\u4ea4\u7533\u8bf7\u65f6&#xff0c;CA\u4f1a\u5bf9\u7533\u8bf7\u8005\u7684\u8eab\u4efd\u8fdb\u884c\u9a8c\u8bc1\u3002\u9a8c\u8bc1\u901a\u8fc7\u540e&#xff0c;CA\u4f1a\u4f7f\u7528\u5176\u79c1\u94a5\u5bf9\u7533\u8bf7\u8005\u7684\u516c\u94a5\u53ca\u76f8\u5173\u4fe1\u606f\u8fdb\u884c\u7b7e\u540d&#xff0c;\u5f62\u6210\u6570\u5b57\u8bc1\u4e66\u5e76\u9881\u53d1\u3002 <\/li>\n<li>  \u64a4\u9500  &#xff1a;\u5982\u679c\u6570\u5b57\u8bc1\u4e66\u7684\u79c1\u94a5\u4e22\u5931\u6216\u8005\u8bc1\u4e66\u6301\u6709\u8005\u7684\u8eab\u4efd\u53d1\u751f\u53d8\u5316&#xff0c;\u7528\u6237\u53ef\u4ee5\u8bf7\u6c42CA\u64a4\u9500\u8bc1\u4e66\u3002\u64a4\u9500\u540e\u7684\u8bc1\u4e66\u5c06\u88ab\u52a0\u5165\u5230\u8bc1\u4e66\u64a4\u9500\u5217\u8868&#xff08;CRL&#xff09;\u4e2d&#xff0c;\u6216\u8005\u4f7f\u7528\u5728\u7ebf\u8bc1\u4e66\u72b6\u6001\u534f\u8bae&#xff08;OCSP&#xff09;\u8fdb\u884c\u5b9e\u65f6\u67e5\u8be2\u3002 <\/li>\n<li>  \u66f4\u65b0  &#xff1a;\u6570\u5b57\u8bc1\u4e66\u662f\u6709\u6709\u6548\u671f\u7684\u3002\u8bc1\u4e66\u5373\u5c06\u8fc7\u671f\u65f6&#xff0c;\u9700\u8981\u5411CA\u7533\u8bf7\u66f4\u65b0&#xff0c;\u5426\u5219\u8bc1\u4e66\u5c06\u5931\u6548\u3002 <\/li>\n<\/ul>\n<h4> 6.2.3 \u53cc\u56e0\u7d20\u8ba4\u8bc1\u7684\u5b9e\u73b0\u65b9\u6cd5 <\/h4>\n<p> \u53cc\u56e0\u7d20\u8ba4\u8bc1&#xff08;Two-factor authentication, 2FA&#xff09;\u662f\u6307\u5229\u7528\u4e24\u79cd\u4e0d\u540c\u7684\u8ba4\u8bc1\u624b\u6bb5\u6765\u589e\u5f3a\u5b89\u5168\u6027\u3002\u901a\u5e38&#xff0c;\u8fd9\u4e9b\u624b\u6bb5\u5305\u62ec&#xff1a; <\/p>\n<ul>\n<li> \u77e5\u8bc6\u56e0\u7d20&#xff1a;\u7528\u6237\u77e5\u9053\u7684\u4fe1\u606f&#xff0c;\u5982\u5bc6\u7801&#xff1b; <\/li>\n<li> \u62e5\u6709\u56e0\u7d20&#xff1a;\u7528\u6237\u62e5\u6709\u7684\u5b9e\u4f53&#xff0c;\u5982\u624b\u673a\u6216\u5b89\u5168\u4ee4\u724c&#xff1b; <\/li>\n<li> \u5185\u5728\u56e0\u7d20&#xff1a;\u7528\u6237\u7684\u751f\u7269\u7279\u5f81&#xff0c;\u5982\u6307\u7eb9\u3001\u9762\u90e8\u8bc6\u522b\u3002 <\/li>\n<\/ul>\n<p> \u5b9e\u73b02FA&#xff0c;\u7528\u6237\u9996\u5148\u9700\u8981\u63d0\u4f9b\u77e5\u8bc6\u56e0\u7d20&#xff0c;\u7136\u540e\u63d0\u4f9b\u62e5\u6709\u56e0\u7d20\u6216\u5185\u5728\u56e0\u7d20\u4e2d\u7684\u4efb\u610f\u4e00\u4e2a\u3002\u6bd4\u5982&#xff0c;\u5728\u7ebf\u670d\u52a1\u8981\u6c42\u7528\u6237\u8f93\u5165\u5bc6\u7801&#xff08;\u77e5\u8bc6\u56e0\u7d20&#xff09;&#xff0c;\u7136\u540e\u8f93\u5165\u4ece\u624b\u673a\u63a5\u6536\u5230\u7684\u4e00\u6b21\u6027\u9a8c\u8bc1\u7801&#xff08;\u62e5\u6709\u56e0\u7d20&#xff09;\u3002\u8fd9\u6837\u7684\u53cc\u91cd\u9a8c\u8bc1\u5927\u5927\u589e\u52a0\u4e86\u5b89\u5168\u6027\u3002 <\/p>\n<h3> 6.3 \u7f51\u7edc\u653b\u51fb\u9632\u8303\u4e0e\u5e94\u6025\u54cd\u5e94 <\/h3>\n<p> \u7f51\u7edc\u653b\u51fb\u662f\u4e92\u8054\u7f51\u5b89\u5168\u4e2d\u4e0d\u53ef\u5ffd\u89c6\u7684\u4e00\u90e8\u5206&#xff0c;\u7f51\u7edc\u9632\u5fa1\u548c\u5e94\u6025\u54cd\u5e94\u673a\u5236\u662f\u4fdd\u969c\u7cfb\u7edf\u5b89\u5168\u7684\u91cd\u8981\u73af\u8282\u3002 <\/p>\n<h4> 6.3.1 \u5e38\u89c1\u7f51\u7edc\u653b\u51fb\u7c7b\u578b\u53ca\u9632\u62a4\u7b56\u7565 <\/h4>\n<p> \u7f51\u7edc\u653b\u51fb\u53ef\u4ee5\u5206\u4e3a\u5f88\u591a\u7c7b\u578b&#xff0c;\u5176\u4e2d\u6bd4\u8f83\u5e38\u89c1\u7684\u6709&#xff1a; <\/p>\n<ul>\n<li>  \u62d2\u7edd\u670d\u52a1\u653b\u51fb&#xff08;DoS\/DDoS&#xff09;  &#xff1a;\u901a\u8fc7\u53d1\u9001\u5927\u91cf\u8bf7\u6c42\u4f7f\u670d\u52a1\u4e0d\u53ef\u7528\u3002\u9632\u62a4\u63aa\u65bd\u5305\u62ec\u9650\u5236\u8fde\u63a5\u6570\u3001\u8bbe\u7f6e\u6d41\u91cf\u76d1\u63a7\u7b49\u3002 <\/li>\n<li>  \u4e2d\u95f4\u4eba\u653b\u51fb&#xff08;MITM&#xff09;  &#xff1a;\u653b\u51fb\u8005\u63d2\u5165\u901a\u4fe1\u53cc\u65b9\u4e2d\u95f4&#xff0c;\u622a\u53d6\u6216\u7be1\u6539\u4fe1\u606f\u3002\u53ef\u4ee5\u4f7f\u7528SSL\/TLS\u7b49\u52a0\u5bc6\u534f\u8bae\u8fdb\u884c\u9632\u8303\u3002 <\/li>\n<li>  \u9493\u9c7c\u653b\u51fb  &#xff1a;\u901a\u8fc7\u5047\u5192\u7f51\u7ad9\u6216\u90ae\u4ef6\u8bf1\u5bfc\u7528\u6237\u63d0\u4f9b\u654f\u611f\u4fe1\u606f\u3002\u7528\u6237\u6559\u80b2\u548c\u591a\u56e0\u7d20\u8ba4\u8bc1\u673a\u5236\u53ef\u4ee5\u51cf\u5c11\u8fd9\u7c7b\u653b\u51fb\u3002 <\/li>\n<\/ul>\n<h4> 6.3.2 \u5b89\u5168\u4e8b\u4ef6\u7684\u76d1\u6d4b\u4e0e\u54cd\u5e94\u6d41\u7a0b <\/h4>\n<p> \u5b89\u5168\u4e8b\u4ef6\u7684\u76d1\u6d4b\u548c\u54cd\u5e94\u662f\u4e00\u4e2a\u52a8\u6001\u7684\u8fc7\u7a0b&#xff0c;\u5305\u62ec&#xff1a; <\/p>\n<ul>\n<li>  \u76d1\u6d4b  &#xff1a;\u5b9e\u65f6\u76d1\u63a7\u7cfb\u7edf\u65e5\u5fd7&#xff0c;\u5bfb\u627e\u5f02\u5e38\u884c\u4e3a\u3002 <\/li>\n<li>  \u5206\u6790  &#xff1a;\u4e00\u65e6\u53d1\u73b0\u53ef\u7591\u884c\u4e3a&#xff0c;\u7acb\u5373\u8fdb\u884c\u5206\u6790&#xff0c;\u5224\u65ad\u662f\u5426\u4e3a\u5b89\u5168\u4e8b\u4ef6\u3002 <\/li>\n<li>  \u54cd\u5e94  &#xff1a;\u5bf9\u5df2\u786e\u8ba4\u7684\u5b89\u5168\u4e8b\u4ef6&#xff0c;\u6267\u884c\u9884\u5b9a\u7684\u5e94\u5bf9\u63aa\u65bd&#xff0c;\u5982\u9694\u79bb\u53d7\u5f71\u54cd\u7cfb\u7edf\u3001\u901a\u77e5\u7528\u6237\u7b49\u3002 <\/li>\n<li>  \u6062\u590d  &#xff1a;\u4e8b\u4ef6\u5904\u7406\u5b8c\u6bd5\u540e&#xff0c;\u5bf9\u7cfb\u7edf\u8fdb\u884c\u4fee\u590d&#xff0c;\u66f4\u65b0\u5b89\u5168\u7b56\u7565&#xff0c;\u9632\u6b62\u7c7b\u4f3c\u4e8b\u4ef6\u518d\u6b21\u53d1\u751f\u3002 <\/li>\n<\/ul>\n<h4> 6.3.3 \u6f0f\u6d1e\u7ba1\u7406\u4e0e\u7cfb\u7edf\u66f4\u65b0\u7b56\u7565 <\/h4>\n<p> \u5bf9\u5df2\u77e5\u7684\u8f6f\u4ef6\u6f0f\u6d1e\u8fdb\u884c\u7ba1\u7406&#xff0c;\u5e76\u53ca\u65f6\u66f4\u65b0\u7cfb\u7edf\u662f\u51cf\u5c11\u5b89\u5168\u98ce\u9669\u7684\u6709\u6548\u624b\u6bb5\u3002\u4e00\u5957\u6709\u6548\u7684\u6f0f\u6d1e\u7ba1\u7406\u4e0e\u66f4\u65b0\u7b56\u7565\u5e94\u5305\u62ec&#xff1a; <\/p>\n<ul>\n<li>  \u6f0f\u6d1e\u8bc6\u522b  &#xff1a;\u4f7f\u7528\u6f0f\u6d1e\u626b\u63cf\u5de5\u5177&#xff0c;\u5b9a\u671f\u5bf9\u7cfb\u7edf\u8fdb\u884c\u6f0f\u6d1e\u626b\u63cf\u3002 <\/li>\n<li>  \u6f0f\u6d1e\u8bc4\u4f30  &#xff1a;\u6839\u636e\u6f0f\u6d1e\u7684\u4e25\u91cd\u6027\u3001\u5f71\u54cd\u8303\u56f4\u7b49\u8fdb\u884c\u8bc4\u4f30&#xff0c;\u786e\u5b9a\u4f18\u5148\u7ea7\u3002 <\/li>\n<li>  \u4fee\u590d\u4e0e\u66f4\u65b0  &#xff1a;\u5bf9\u9ad8\u5371\u6f0f\u6d1e&#xff0c;\u5e94\u5c3d\u5feb\u5e94\u7528\u8865\u4e01\u6216\u66f4\u65b0\u8f6f\u4ef6\u7248\u672c\u3002 <\/li>\n<li>  \u76d1\u63a7\u4e0e\u9a8c\u8bc1  &#xff1a;\u66f4\u65b0\u540e\u8981\u8fdb\u884c\u6d4b\u8bd5&#xff0c;\u786e\u4fdd\u66f4\u65b0\u6ca1\u6709\u5f15\u5165\u65b0\u7684\u95ee\u9898&#xff0c;\u5e76\u6709\u6548\u4fee\u590d\u4e86\u5df2\u77e5\u6f0f\u6d1e\u3002 <\/li>\n<\/ul>\n<p> \u901a\u8fc7\u5bf9\u7f51\u7edc\u6570\u636e\u4f20\u8f93\u5b89\u5168\u7684\u4e0d\u61c8\u8ffd\u6c42\u548c\u6301\u7eed\u4f18\u5316&#xff0c;\u6211\u4eec\u53ef\u4ee5\u5728\u6700\u5927\u7a0b\u5ea6\u4e0a\u51cf\u5c11\u6570\u636e\u6cc4\u9732\u548c\u6ee5\u7528\u7684\u98ce\u9669&#xff0c;\u4fdd\u62a4\u7528\u6237\u548c\u4f01\u4e1a\u7684\u5229\u76ca\u3002 <\/p>\n<p>  \u672c\u6587\u8fd8\u6709\u914d\u5957\u7684\u7cbe\u54c1\u8d44\u6e90&#xff0c;\u70b9\u51fb\u83b7\u53d6  <img decoding=\"async\" alt=\"menu-r.4af5f7ec.gif\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250812155953-689b64f92202d.gif\" style=\"width:16px;margin-left:4px;vertical-align:text-bottom;cursor:text\" \/> <\/p>\n<p> \u7b80\u4ecb&#xff1a;\u5728IT\u9886\u57df&#xff0c;\u5ba2\u6237\u7aef-\u670d\u52a1\u5668&#xff08;Client-Sever&#xff09;\u67b6\u6784\u662f\u5e38\u89c1\u7684\u7f51\u7edc\u901a\u4fe1\u6a21\u5f0f&#xff0c;\u7528\u4e8e\u5904\u7406\u5e94\u7528\u7a0b\u5e8f\u5982\u767b\u5f55\u3001\u6ce8\u518c\u3001\u804a\u5929\u7cfb\u7edf\u7b49\u3002\u5ba2\u6237\u7aef\u8fd0\u884c\u5728\u7528\u6237\u8bbe\u5907\u4e0a&#xff0c;\u670d\u52a1\u5668\u8fd0\u884c\u5728\u8fdc\u7a0b\u4e3b\u673a\u4e0a\u5904\u7406\u6570\u636e\u548c\u670d\u52a1\u8bf7\u6c42\u3002\u670d\u52a1\u5668\u901a\u5e38\u901a\u8fc7Socket\u63a5\u53e3\u4e0e\u5ba2\u6237\u7aef\u901a\u4fe1&#xff0c;\u4f7f\u7528TCP\/IP\u6216UDP\u534f\u8bae\u3002\u5728\u5b9e\u73b0\u767b\u5f55\u3001\u6ce8\u518c\u548c\u804a\u5929\u65f6&#xff0c;\u670d\u52a1\u5668\u7aef\u4f1a\u8fdb\u884c\u8eab\u4efd\u9a8c\u8bc1\u3001\u6570\u636e\u5e93\u64cd\u4f5c&#xff0c;\u5e76\u786e\u4fdd\u901a\u4fe1\u5b89\u5168\u3002\u540c\u65f6&#xff0c;\u8fd8\u9700\u8981\u8003\u8651\u6027\u80fd\u3001\u9519\u8bef\u5904\u7406\u548c\u5e76\u53d1\u63a7\u5236&#xff0c;\u4ee5\u4f18\u5316\u7528\u6237\u4f53\u9a8c\u3002 <\/p>\n<p>   \u672c\u6587\u8fd8\u6709\u914d\u5957\u7684\u7cbe\u54c1\u8d44\u6e90&#xff0c;\u70b9\u51fb\u83b7\u53d6   <img decoding=\"async\" alt=\"menu-r.4af5f7ec.gif\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250812155953-689b64f92202d.gif\" style=\"width:16px;margin-left:4px;vertical-align:text-bottom;cursor:text\" \/>  <\/p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb819\u6b21\uff0c\u70b9\u8d5e7\u6b21\uff0c\u6536\u85cf22\u6b21\u3002\u5ba2\u6237\u7aef-\u670d\u52a1\u5668\uff08Client-Server\uff09\u67b6\u6784\u662f\u4e00\u79cd\u5206\u5e03\u5f0f\u8ba1\u7b97\u6a21\u578b\uff0c\u5176\u6838\u5fc3\u5728\u4e8e\u5c06\u4efb\u52a1\u5206\u4e3a\u4e24\u90e8\u5206\uff0c\u4e00\u90e8\u5206\u7531\u5ba2\u6237\u7aef\u5b8c\u6210\uff0c\u53e6\u4e00\u90e8\u5206\u7531\u670d\u52a1\u5668\u7aef\u5904\u7406\u3002\u8fd9\u79cd\u6a21\u5f0f\u7684\u7279\u70b9\u662f\u9ad8\u5ea6\u6a21\u5757\u5316\uff0c\u6613\u4e8e\u6269\u5c55\u548c\u7ef4\u62a4\u3002Socket\uff0c\u4e5f\u79f0\u4e3a\u5957\u63a5\u5b57\uff0c\u662f\u4e00\u79cd\u7f51\u7edc\u901a\u4fe1\u7684\u7aef\u70b9\uff0c\u5141\u8bb8\u4e24\u4e2a\u7a0b\u5e8f\u4e4b\u95f4\u8fdb\u884c\u6570\u636e\u4f20\u8f93\u3002\u5b83\u662f\u7f51\u7edc\u901a\u4fe1\u7684\u57fa\u7840\uff0c\u63d0\u4f9b\u4e86\u5e94\u7528\u7a0b\u5e8f\u4e0e\u7f51\u7edc\u534f\u8bae\u6808\u4e4b\u95f4\u7684\u62bd\u8c61\u5c42\uff0c\u4ee5\u4fbf\u8fdb\u884c\u6570\u636e\u4ea4\u6362\u3002\u5728TCP\/IP\u534f\u8bae\u4e2d\uff0c\u5e38\u89c1\u7684Socket\u7c7b\u578b\u5305\u62ec\u6d41\u5f0f\u5957\u63a5\u5b57\uff08SOCK_STREAM\uff09\u548c\u6570\u636e\u62a5\u5957\u63a5\u5b57\uff08SOCK_DGRAM\uff09\u3002<\/p>\n","protected":false},"author":2,"featured_media":54214,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"topic":[],"class_list":["post-54216","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u6df1\u5165\u7406\u89e3\u5ba2\u6237\u7aef-\u670d\u52a1\u5668\u7f51\u7edc\u901a\u4fe1\u67b6\u6784 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/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:\/\/www.wsisp.com\/helps\/54216.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u6df1\u5165\u7406\u89e3\u5ba2\u6237\u7aef-\u670d\u52a1\u5668\u7f51\u7edc\u901a\u4fe1\u67b6\u6784 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb819\u6b21\uff0c\u70b9\u8d5e7\u6b21\uff0c\u6536\u85cf22\u6b21\u3002\u5ba2\u6237\u7aef-\u670d\u52a1\u5668\uff08Client-Server\uff09\u67b6\u6784\u662f\u4e00\u79cd\u5206\u5e03\u5f0f\u8ba1\u7b97\u6a21\u578b\uff0c\u5176\u6838\u5fc3\u5728\u4e8e\u5c06\u4efb\u52a1\u5206\u4e3a\u4e24\u90e8\u5206\uff0c\u4e00\u90e8\u5206\u7531\u5ba2\u6237\u7aef\u5b8c\u6210\uff0c\u53e6\u4e00\u90e8\u5206\u7531\u670d\u52a1\u5668\u7aef\u5904\u7406\u3002\u8fd9\u79cd\u6a21\u5f0f\u7684\u7279\u70b9\u662f\u9ad8\u5ea6\u6a21\u5757\u5316\uff0c\u6613\u4e8e\u6269\u5c55\u548c\u7ef4\u62a4\u3002Socket\uff0c\u4e5f\u79f0\u4e3a\u5957\u63a5\u5b57\uff0c\u662f\u4e00\u79cd\u7f51\u7edc\u901a\u4fe1\u7684\u7aef\u70b9\uff0c\u5141\u8bb8\u4e24\u4e2a\u7a0b\u5e8f\u4e4b\u95f4\u8fdb\u884c\u6570\u636e\u4f20\u8f93\u3002\u5b83\u662f\u7f51\u7edc\u901a\u4fe1\u7684\u57fa\u7840\uff0c\u63d0\u4f9b\u4e86\u5e94\u7528\u7a0b\u5e8f\u4e0e\u7f51\u7edc\u534f\u8bae\u6808\u4e4b\u95f4\u7684\u62bd\u8c61\u5c42\uff0c\u4ee5\u4fbf\u8fdb\u884c\u6570\u636e\u4ea4\u6362\u3002\u5728TCP\/IP\u534f\u8bae\u4e2d\uff0c\u5e38\u89c1\u7684Socket\u7c7b\u578b\u5305\u62ec\u6d41\u5f0f\u5957\u63a5\u5b57\uff08SOCK_STREAM\uff09\u548c\u6570\u636e\u62a5\u5957\u63a5\u5b57\uff08SOCK_DGRAM\uff09\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/54216.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-08-12T15:59:54+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250812155953-689b64f92202d.gif\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/54216.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/54216.html\",\"name\":\"\u6df1\u5165\u7406\u89e3\u5ba2\u6237\u7aef-\u670d\u52a1\u5668\u7f51\u7edc\u901a\u4fe1\u67b6\u6784 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-08-12T15:59:54+00:00\",\"dateModified\":\"2025-08-12T15:59:54+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/54216.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/54216.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/54216.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u6df1\u5165\u7406\u89e3\u5ba2\u6237\u7aef-\u670d\u52a1\u5668\u7f51\u7edc\u901a\u4fe1\u67b6\u6784\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u6df1\u5165\u7406\u89e3\u5ba2\u6237\u7aef-\u670d\u52a1\u5668\u7f51\u7edc\u901a\u4fe1\u67b6\u6784 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","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:\/\/www.wsisp.com\/helps\/54216.html","og_locale":"zh_CN","og_type":"article","og_title":"\u6df1\u5165\u7406\u89e3\u5ba2\u6237\u7aef-\u670d\u52a1\u5668\u7f51\u7edc\u901a\u4fe1\u67b6\u6784 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb819\u6b21\uff0c\u70b9\u8d5e7\u6b21\uff0c\u6536\u85cf22\u6b21\u3002\u5ba2\u6237\u7aef-\u670d\u52a1\u5668\uff08Client-Server\uff09\u67b6\u6784\u662f\u4e00\u79cd\u5206\u5e03\u5f0f\u8ba1\u7b97\u6a21\u578b\uff0c\u5176\u6838\u5fc3\u5728\u4e8e\u5c06\u4efb\u52a1\u5206\u4e3a\u4e24\u90e8\u5206\uff0c\u4e00\u90e8\u5206\u7531\u5ba2\u6237\u7aef\u5b8c\u6210\uff0c\u53e6\u4e00\u90e8\u5206\u7531\u670d\u52a1\u5668\u7aef\u5904\u7406\u3002\u8fd9\u79cd\u6a21\u5f0f\u7684\u7279\u70b9\u662f\u9ad8\u5ea6\u6a21\u5757\u5316\uff0c\u6613\u4e8e\u6269\u5c55\u548c\u7ef4\u62a4\u3002Socket\uff0c\u4e5f\u79f0\u4e3a\u5957\u63a5\u5b57\uff0c\u662f\u4e00\u79cd\u7f51\u7edc\u901a\u4fe1\u7684\u7aef\u70b9\uff0c\u5141\u8bb8\u4e24\u4e2a\u7a0b\u5e8f\u4e4b\u95f4\u8fdb\u884c\u6570\u636e\u4f20\u8f93\u3002\u5b83\u662f\u7f51\u7edc\u901a\u4fe1\u7684\u57fa\u7840\uff0c\u63d0\u4f9b\u4e86\u5e94\u7528\u7a0b\u5e8f\u4e0e\u7f51\u7edc\u534f\u8bae\u6808\u4e4b\u95f4\u7684\u62bd\u8c61\u5c42\uff0c\u4ee5\u4fbf\u8fdb\u884c\u6570\u636e\u4ea4\u6362\u3002\u5728TCP\/IP\u534f\u8bae\u4e2d\uff0c\u5e38\u89c1\u7684Socket\u7c7b\u578b\u5305\u62ec\u6d41\u5f0f\u5957\u63a5\u5b57\uff08SOCK_STREAM\uff09\u548c\u6570\u636e\u62a5\u5957\u63a5\u5b57\uff08SOCK_DGRAM\uff09\u3002","og_url":"https:\/\/www.wsisp.com\/helps\/54216.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-08-12T15:59:54+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250812155953-689b64f92202d.gif"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"9 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/54216.html","url":"https:\/\/www.wsisp.com\/helps\/54216.html","name":"\u6df1\u5165\u7406\u89e3\u5ba2\u6237\u7aef-\u670d\u52a1\u5668\u7f51\u7edc\u901a\u4fe1\u67b6\u6784 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-08-12T15:59:54+00:00","dateModified":"2025-08-12T15:59:54+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/54216.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/54216.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/54216.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u6df1\u5165\u7406\u89e3\u5ba2\u6237\u7aef-\u670d\u52a1\u5668\u7f51\u7edc\u901a\u4fe1\u67b6\u6784"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/54216","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=54216"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/54216\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/54214"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=54216"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=54216"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=54216"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=54216"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}