{"id":86249,"date":"2024-01-05T17:53:11","date_gmt":"2024-01-05T09:53:11","guid":{"rendered":"http:\/\/lrxjmw.cn\/?p=86249"},"modified":"2024-01-05T17:53:11","modified_gmt":"2024-01-05T09:53:11","slug":"introduce-concurrency-server","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/introduce-concurrency-server.html","title":{"rendered":"\u7b80\u8981\u4ecb\u7ecd\u5e76\u53d1\u670d\u52a1\u5668"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u8fd9\u662f\u5173\u4e8e\u5e76\u53d1\u7f51\u7edc\u670d\u52a1\u5668\u7f16\u7a0b\u7684\u7b2c\u4e00\u7bc7\u6559\u7a0b\u3002\u6211\u8ba1\u5212\u6d4b\u8bd5\u51e0\u4e2a\u4e3b\u6d41\u7684\u3001\u53ef\u4ee5\u540c\u65f6\u5904\u7406\u591a\u4e2a\u5ba2\u6237\u7aef\u8bf7\u6c42\u7684\u670d\u52a1\u5668\u5e76\u53d1\u6a21\u578b\uff0c\u57fa\u4e8e\u53ef\u6269\u5c55\u6027\u548c\u6613\u5b9e\u73b0\u6027\u5bf9\u8fd9\u4e9b\u6a21\u578b\u8fdb\u884c\u8bc4\u5224\u3002\u6240\u6709\u7684\u670d\u52a1\u5668\u90fd\u4f1a\u76d1\u542c\u5957\u63a5\u5b57\u8fde\u63a5\uff0c\u5e76\u4e14\u5b9e\u73b0\u4e00\u4e9b\u7b80\u5355\u7684\u534f\u8bae\u7528\u4e8e\u4e0e\u5ba2\u6237\u7aef\u8fdb\u884c\u901a\u8baf\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\"\"<\/p>\n

<\/h3>\n
\u5185\u5bb9<\/strong><\/div>\n

\u8be5\u7cfb\u5217\u6559\u7a0b\u6240\u7528\u7684\u534f\u8bae\u90fd\u975e\u5e38\u7b80\u5355\uff0c\u4f46\u8db3\u4ee5\u5c55\u793a\u5e76\u53d1\u670d\u52a1\u5668\u8bbe\u8ba1\u7684\u8bb8\u591a\u6709\u8da3\u5c42\u9762\u3002\u800c\u4e14\u8fd9\u4e2a\u534f\u8bae\u662f\u00a0\u6709\u72b6\u6001\u7684<\/em>\u2014\u2014 \u670d\u52a1\u5668\u6839\u636e\u5ba2\u6237\u7aef\u53d1\u9001\u7684\u6570\u636e\u6539\u53d8\u5185\u90e8\u72b6\u6001\uff0c\u7136\u540e\u6839\u636e\u5185\u90e8\u72b6\u6001\u4ea7\u751f\u76f8\u5e94\u7684\u884c\u4e3a\u3002\u5e76\u975e\u6240\u6709\u7684\u534f\u8bae\u90fd\u662f\u6709\u72b6\u6001\u7684 \u2014\u2014 \u5b9e\u9645\u4e0a\uff0c\u57fa\u4e8e HTTP \u7684\u8bb8\u591a\u534f\u8bae\u662f\u65e0\u72b6\u6001\u7684\uff0c\u4f46\u662f\u6709\u72b6\u6001\u7684\u534f\u8bae\u4e5f\u662f\u5f88\u5e38\u89c1\uff0c\u503c\u5f97\u8ba4\u771f\u8ba8\u8bba\u3002<\/p>\n

\u5728\u670d\u52a1\u5668\u7aef\u770b\u6765\uff0c\u8fd9\u4e2a\u534f\u8bae\u7684\u89c6\u56fe\u662f\u8fd9\u6837\u7684\uff1a<\/p>\n

\"\"<\/p>\n

\u603b\u4e4b\uff1a\u670d\u52a1\u5668\u7b49\u5f85\u65b0\u5ba2\u6237\u7aef\u7684\u8fde\u63a5\uff1b\u5f53\u4e00\u4e2a\u5ba2\u6237\u7aef\u8fde\u63a5\u7684\u65f6\u5019\uff0c\u670d\u52a1\u5668\u4f1a\u5411\u8be5\u5ba2\u6237\u7aef\u53d1\u9001\u4e00\u4e2a\u00a0*\u00a0\u5b57\u7b26\uff0c\u8fdb\u5165\u201c\u7b49\u5f85\u6d88\u606f\u201d\u7684\u72b6\u6001\u3002\u5728\u8be5\u72b6\u6001\u4e0b\uff0c\u670d\u52a1\u5668\u4f1a\u5ffd\u7565\u5ba2\u6237\u7aef\u53d1\u9001\u7684\u6240\u6709\u5b57\u7b26\uff0c\u9664\u975e\u5b83\u770b\u5230\u4e86\u4e00\u4e2a\u00a0^\u00a0\u5b57\u7b26\uff0c\u8fd9\u8868\u793a\u4e00\u4e2a\u65b0\u6d88\u606f\u7684\u5f00\u59cb\u3002\u8fd9\u4e2a\u65f6\u5019\u670d\u52a1\u5668\u5c31\u4f1a\u8f6c\u53d8\u4e3a\u201c\u6b63\u5728\u901a\u4fe1\u201d\u7684\u72b6\u6001\uff0c\u8fd9\u65f6\u5b83\u4f1a\u5411\u5ba2\u6237\u7aef\u56de\u9001\u6570\u636e\uff0c\u628a\u6536\u5230\u7684\u6240\u6709\u5b57\u7b26\u7684\u6bcf\u4e2a\u5b57\u8282\u52a0 1 \u56de\u9001\u7ed9\u5ba2\u6237\u7aef\u6ce81<\/sup>\u00a0\u3002\u5f53\u5ba2\u6237\u7aef\u53d1\u9001\u4e86\u00a0$\u00a0\u5b57\u7b26\uff0c\u670d\u52a1\u5668\u5c31\u4f1a\u9000\u56de\u5230\u7b49\u5f85\u65b0\u6d88\u606f\u7684\u72b6\u6001\u3002^\u00a0\u548c\u00a0$\u00a0\u5b57\u7b26\u4ec5\u4ec5\u7528\u4e8e\u5206\u9694\u6d88\u606f \u2014\u2014 \u5b83\u4eec\u4e0d\u4f1a\u88ab\u670d\u52a1\u5668\u56de\u9001\u3002<\/p>\n

\u6bcf\u4e2a\u72b6\u6001\u4e4b\u540e\u90fd\u6709\u4e2a\u9690\u85cf\u7684\u7bad\u5934\u6307\u5411 \u201c\u7b49\u5f85\u5ba2\u6237\u7aef\u201d \u72b6\u6001\uff0c\u7528\u4e8e\u5ba2\u6237\u7aef\u65ad\u5f00\u8fde\u63a5\u3002\u56e0\u6b64\uff0c\u5ba2\u6237\u7aef\u8981\u8868\u793a\u201c\u6211\u5df2\u7ecf\u7ed3\u675f\u201d\u7684\u65b9\u6cd5\u5f88\u7b80\u5355\uff0c\u5173\u6389\u5b83\u90a3\u4e00\u7aef\u7684\u8fde\u63a5\u5c31\u597d\u3002<\/p>\n

\u663e\u7136\uff0c\u8fd9\u4e2a\u534f\u8bae\u662f\u771f\u5b9e\u534f\u8bae\u7684\u7b80\u5316\u7248\uff0c\u771f\u5b9e\u4f7f\u7528\u7684\u534f\u8bae\u4e00\u822c\u5305\u542b\u590d\u6742\u7684\u62a5\u6587\u5934\u3001\u8f6c\u4e49\u5b57\u7b26\u5e8f\u5217\uff08\u4f8b\u5982\u8ba9\u6d88\u606f\u4f53\u4e2d\u53ef\u4ee5\u51fa\u73b0\u00a0$\u00a0\u7b26\u53f7\uff09\uff0c\u989d\u5916\u7684\u72b6\u6001\u53d8\u5316\u3002\u4f46\u662f\u6211\u4eec\u8fd9\u4e2a\u534f\u8bae\u8db3\u4ee5\u5b8c\u6210\u671f\u671b\u3002<\/p>\n

\u53e6\u4e00\u70b9\uff1a\u8fd9\u4e2a\u7cfb\u5217\u662f\u4ecb\u7ecd\u6027\u7684\uff0c\u5e76\u5047\u8bbe\u5ba2\u6237\u7aef\u90fd\u5de5\u4f5c\u7684\u5f88\u597d\uff08\u867d\u7136\u53ef\u80fd\u8fd0\u884c\u5f88\u6162\uff09\uff1b\u56e0\u6b64\u6ca1\u6709\u8bbe\u7f6e\u8d85\u65f6\uff0c\u4e5f\u6ca1\u6709\u8bbe\u7f6e\u7279\u6b8a\u7684\u89c4\u5219\u6765\u786e\u4fdd\u670d\u52a1\u5668\u4e0d\u4f1a\u56e0\u4e3a\u5ba2\u6237\u7aef\u7684\u6076\u610f\u884c\u4e3a\uff08\u6216\u662f\u6545\u969c\uff09\u800c\u51fa\u73b0\u963b\u585e\uff0c\u5bfc\u81f4\u4e0d\u80fd\u6b63\u5e38\u7ed3\u675f\u3002<\/p>\n

\u987a\u5e8f\u670d\u52a1\u5668<\/strong><\/div>\n

\u8fd9\u4e2a\u7cfb\u5217\u4e2d\u6211\u4eec\u7684\u7b2c\u4e00\u4e2a\u670d\u52a1\u7aef\u7a0b\u5e8f\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u201c\u987a\u5e8f\u201d\u670d\u52a1\u5668\uff0c\u7528 C \u8fdb\u884c\u7f16\u5199\uff0c\u9664\u4e86\u6807\u51c6\u7684 POSIX \u4e2d\u7528\u4e8e\u5957\u63a5\u5b57\u7684\u5185\u5bb9\u4ee5\u5916\u6ca1\u6709\u4f7f\u7528\u5176\u5b83\u5e93\u3002\u670d\u52a1\u5668\u7a0b\u5e8f\u662f\u987a\u5e8f\uff0c\u56e0\u4e3a\u5b83\u4e00\u6b21\u53ea\u80fd\u5904\u7406\u4e00\u4e2a\u5ba2\u6237\u7aef\u7684\u8bf7\u6c42\uff1b\u5f53\u6709\u5ba2\u6237\u7aef\u8fde\u63a5\u65f6\uff0c\u50cf\u4e4b\u524d\u6240\u8bf4\u7684\u90a3\u6837\uff0c\u670d\u52a1\u5668\u4f1a\u8fdb\u5165\u5230\u72b6\u6001\u673a\u4e2d\uff0c\u5e76\u4e14\u4e0d\u518d\u76d1\u542c\u5957\u63a5\u5b57\u63a5\u53d7\u65b0\u7684\u5ba2\u6237\u7aef\u8fde\u63a5\uff0c\u76f4\u5230\u5f53\u524d\u7684\u5ba2\u6237\u7aef\u7ed3\u675f\u8fde\u63a5\u3002\u663e\u7136\u8fd9\u4e0d\u662f\u5e76\u53d1\u7684\uff0c\u800c\u4e14\u5373\u4fbf\u5728\u5f88\u5c11\u7684\u8d1f\u8f7d\u4e0b\u4e5f\u4e0d\u80fd\u670d\u52a1\u591a\u4e2a\u5ba2\u6237\u7aef\uff0c\u4f46\u5b83\u5bf9\u4e8e\u6211\u4eec\u7684\u8ba8\u8bba\u5f88\u6709\u7528\uff0c\u56e0\u4e3a\u6211\u4eec\u9700\u8981\u7684\u662f\u4e00\u4e2a\u6613\u4e8e\u7406\u89e3\u7684\u57fa\u7840\u3002<\/p>\n

\u8fd9\u4e2a\u670d\u52a1\u5668\u7684\u5b8c\u6574\u4ee3\u7801\u5728\u8fd9\u91cc\uff1b\u63a5\u4e0b\u6765\uff0c\u6211\u4f1a\u7740\u91cd\u4e8e\u4e00\u4e9b\u91cd\u70b9\u7684\u90e8\u5206\u3002main\u00a0\u51fd\u6570\u91cc\u9762\u7684\u5916\u5c42\u5faa\u73af\u7528\u4e8e\u76d1\u542c\u5957\u63a5\u5b57\uff0c\u4ee5\u4fbf\u63a5\u53d7\u65b0\u5ba2\u6237\u7aef\u7684\u8fde\u63a5\u3002\u4e00\u65e6\u6709\u5ba2\u6237\u7aef\u8fdb\u884c\u8fde\u63a5\uff0c\u5c31\u4f1a\u8c03\u7528\u00a0serve_connection\uff0c\u8fd9\u4e2a\u51fd\u6570\u4e2d\u7684\u4ee3\u7801\u4f1a\u4e00\u76f4\u8fd0\u884c\uff0c\u76f4\u5230\u5ba2\u6237\u7aef\u65ad\u5f00\u8fde\u63a5\u3002<\/p>\n

\u987a\u5e8f\u670d\u52a1\u5668\u5728\u5faa\u73af\u91cc\u8c03\u7528\u00a0accept\u00a0\u7528\u6765\u76d1\u542c\u5957\u63a5\u5b57\uff0c\u5e76\u63a5\u53d7\u65b0\u8fde\u63a5\uff1a<\/p>\n

 \twhile (1) {\r\n  struct sockaddr_in peer_addr;\r\n  socklen_t peer_addr_len = sizeof(peer_addr);\r\n  int newsockfd =\r\n      accept(sockfd, (struct sockaddr*)&peer_addr, &peer_addr_len);\r\n  if (newsockfd < 0) {\r\n    perror_die(\"ERROR on accept\");\r\n  }\r\n  report_peer_connected(&peer_addr, peer_addr_len);\r\n  serve_connection(newsockfd);\r\n  printf(\"peer done\\n\");\r\n}\r\n<\/pre>\n

accept\u00a0\u51fd\u6570\u6bcf\u6b21\u90fd\u4f1a\u8fd4\u56de\u4e00\u4e2a\u65b0\u7684\u5df2\u8fde\u63a5\u7684\u5957\u63a5\u5b57\uff0c\u7136\u540e\u670d\u52a1\u5668\u8c03\u7528\u00a0serve_connection\uff1b\u6ce8\u610f\u8fd9\u662f\u4e00\u4e2a\u00a0\u963b\u585e\u5f0f<\/em>\u00a0\u7684\u8c03\u7528 \u2014\u2014 \u5728\u00a0serve_connection\u00a0\u8fd4\u56de\u524d\uff0caccept\u00a0\u51fd\u6570\u90fd\u4e0d\u4f1a\u518d\u88ab\u8c03\u7528\u4e86\uff1b\u670d\u52a1\u5668\u4f1a\u88ab\u963b\u585e\uff0c\u76f4\u5230\u5ba2\u6237\u7aef\u7ed3\u675f\u8fde\u63a5\u624d\u80fd\u63a5\u53d7\u65b0\u7684\u8fde\u63a5\u3002\u6362\u53e5\u8bdd\u8bf4\uff0c\u5ba2\u6237\u7aef\u6309\u00a0\u987a\u5e8f<\/em>\u00a0\u5f97\u5230\u54cd\u5e94\u3002<\/p>\n

\u8fd9\u662f\u00a0serve_connection\u00a0\u51fd\u6570\uff1a<\/p>\n

typedef enum { WAIT_FOR_MSG, IN_MSG } ProcessingState;\r\nvoid serve_connection(int sockfd) {\r\n  if (send(sockfd, \"*\", 1, 0) < 1) {\r\n    perror_die(\"send\");\r\n  }\r\n  ProcessingState state = WAIT_FOR_MSG;\r\n  while (1) {\r\n    uint8_t buf[1024];\r\n    int len = recv(sockfd, buf, sizeof buf, 0);\r\n    if (len < 0) {\r\n      perror_die(\"recv\");\r\n    } else if (len == 0) {\r\n      break;\r\n    }\r\n    for (int i = 0; i < len; ++i) {\r\n      switch (state) {\r\n      case WAIT_FOR_MSG:\r\n        if (buf[i] == '^') {\r\n          state = IN_MSG;\r\n        }\r\n        break;\r\n      case IN_MSG:\r\n        if (buf[i] == '$') {\r\n          state = WAIT_FOR_MSG;\r\n        } else {\r\n          buf[i] += 1;\r\n          if (send(sockfd, &buf[i], 1, 0) < 1) {\r\n            perror(\"send error\");\r\n            close(sockfd);\r\n            return;\r\n          }\r\n        }\r\n        break;\r\n      }\r\n    }\r\n  }\r\n  close(sockfd);\r\n}\r\n<\/pre>\n

\u5b83\u5b8c\u5168\u662f\u6309\u7167\u72b6\u6001\u673a\u534f\u8bae\u8fdb\u884c\u7f16\u5199\u7684\u3002\u6bcf\u6b21\u5faa\u73af\u7684\u65f6\u5019\uff0c\u670d\u52a1\u5668\u5c1d\u8bd5\u63a5\u6536\u5ba2\u6237\u7aef\u7684\u6570\u636e\u3002\u6536\u5230 0 \u5b57\u8282\u610f\u5473\u7740\u5ba2\u6237\u7aef\u65ad\u5f00\u8fde\u63a5\uff0c\u7136\u540e\u5faa\u73af\u5c31\u4f1a\u9000\u51fa\u3002\u5426\u5219\uff0c\u4f1a\u9010\u5b57\u8282\u68c0\u67e5\u63a5\u6536\u7f13\u5b58\uff0c\u6bcf\u4e00\u4e2a\u5b57\u8282\u90fd\u53ef\u80fd\u4f1a\u89e6\u53d1\u4e00\u4e2a\u72b6\u6001\u3002<\/p>\n

recv\u00a0\u51fd\u6570\u8fd4\u56de\u63a5\u6536\u5230\u7684\u5b57\u8282\u6570\u4e0e\u5ba2\u6237\u7aef\u53d1\u9001\u6d88\u606f\u7684\u6570\u91cf\u5b8c\u5168\u65e0\u5173\uff08^...$\u00a0\u95ed\u5408\u5e8f\u5217\u7684\u5b57\u8282\uff09\u3002\u56e0\u6b64\uff0c\u5728\u4fdd\u6301\u72b6\u6001\u7684\u5faa\u73af\u4e2d\u904d\u5386\u6574\u4e2a\u7f13\u51b2\u533a\u5f88\u91cd\u8981\u3002\u800c\u4e14\uff0c\u6bcf\u4e00\u4e2a\u63a5\u6536\u5230\u7684\u7f13\u51b2\u4e2d\u53ef\u80fd\u5305\u542b\u591a\u6761\u4fe1\u606f\uff0c\u4f46\u4e5f\u6709\u53ef\u80fd\u5f00\u59cb\u4e86\u4e00\u4e2a\u65b0\u6d88\u606f\uff0c\u5374\u6ca1\u6709\u663e\u5f0f\u7684\u7ed3\u675f\u5b57\u7b26\uff1b\u800c\u8fd9\u4e2a\u7ed3\u675f\u5b57\u7b26\u53ef\u80fd\u5728\u4e0b\u4e00\u4e2a\u7f13\u51b2\u4e2d\u624d\u80fd\u6536\u5230\uff0c\u8fd9\u5c31\u662f\u5904\u7406\u72b6\u6001\u5728\u5faa\u73af\u8fed\u4ee3\u4e2d\u8fdb\u884c\u7ef4\u62a4\u7684\u539f\u56e0\u3002<\/p>\n

\u4f8b\u5982\uff0c\u8bd5\u60f3\u4e3b\u5faa\u73af\u4e2d\u7684\u00a0recv\u00a0\u51fd\u6570\u5728\u67d0\u6b21\u8fde\u63a5\u4e2d\u8fd4\u56de\u4e86\u4e09\u4e2a\u975e\u7a7a\u7684\u7f13\u51b2\uff1a<\/p>\n

^abc$de^abte$f\r\nxyz^123\r\n25$^ab$abab\r\n<\/pre>\n

\u670d\u52a1\u7aef\u8fd4\u56de\u7684\u662f\u54ea\u4e9b\u6570\u636e\uff1f\u8ffd\u8e2a\u4ee3\u7801\u5bf9\u4e8e\u7406\u89e3\u72b6\u6001\u8f6c\u53d8\u5f88\u6709\u7528\u3002\uff08\u7b54\u6848\u89c1\u6ce82<\/a><\/sup>\u00a0\uff09<\/p>\n

\u591a\u4e2a\u5e76\u53d1\u5ba2\u6237\u7aef<\/strong><\/div>\n

\u5982\u679c\u591a\u4e2a\u5ba2\u6237\u7aef\u5728\u540c\u4e00\u65f6\u523b\u5411\u987a\u5e8f\u670d\u52a1\u5668\u53d1\u8d77\u8fde\u63a5\u4f1a\u53d1\u751f\u4ec0\u4e48\u4e8b\u60c5\uff1f<\/p>\n

\u670d\u52a1\u5668\u7aef\u7684\u4ee3\u7801\uff08\u4ee5\u53ca\u5b83\u7684\u540d\u5b57 \u201c\u987a\u5e8f\u670d\u52a1\u5668\u201d\uff09\u5df2\u7ecf\u8bf4\u7684\u5f88\u6e05\u695a\u4e86\uff0c\u4e00\u6b21\u53ea\u80fd\u5904\u7406\u00a0\u4e00\u4e2a<\/em>\u00a0\u5ba2\u6237\u7aef\u7684\u8bf7\u6c42\u3002\u53ea\u8981\u670d\u52a1\u5668\u5728\u00a0serve_connection\u00a0\u51fd\u6570\u4e2d\u5fd9\u4e8e\u5904\u7406\u5ba2\u6237\u7aef\u7684\u8bf7\u6c42\uff0c\u5c31\u4e0d\u4f1a\u63a5\u53d7\u522b\u7684\u5ba2\u6237\u7aef\u7684\u8fde\u63a5\u3002\u53ea\u6709\u5f53\u524d\u7684\u5ba2\u6237\u7aef\u65ad\u5f00\u4e86\u8fde\u63a5\uff0cserve_connection\u00a0\u624d\u4f1a\u8fd4\u56de\uff0c\u7136\u540e\u6700\u5916\u5c42\u7684\u5faa\u73af\u624d\u80fd\u7ee7\u7eed\u6267\u884c\u63a5\u53d7\u5176\u4ed6\u5ba2\u6237\u7aef\u7684\u8fde\u63a5\u3002<\/p>\n

\u4e3a\u4e86\u6f14\u793a\u8fd9\u4e2a\u884c\u4e3a\uff0c\u8be5\u7cfb\u5217\u6559\u7a0b\u7684\u793a\u4f8b\u4ee3\u7801\u00a0\u5305\u542b\u4e86\u4e00\u4e2a Python \u811a\u672c\uff0c\u7528\u4e8e\u6a21\u62df\u51e0\u4e2a\u60f3\u8981\u540c\u65f6\u8fde\u63a5\u670d\u52a1\u5668\u7684\u5ba2\u6237\u7aef\u3002\u6bcf\u4e00\u4e2a\u5ba2\u6237\u7aef\u53d1\u9001\u7c7b\u4f3c\u4e4b\u524d\u90a3\u6837\u7684\u4e09\u4e2a\u6570\u636e\u7f13\u51b2\u00a0\u6ce83<\/sup>\u00a0\uff0c\u4e0d\u8fc7\u6bcf\u6b21\u53d1\u9001\u6570\u636e\u4e4b\u95f4\u4f1a\u6709\u4e00\u5b9a\u5ef6\u8fdf\u3002<\/p>\n

\u5ba2\u6237\u7aef\u811a\u672c\u5728\u4e0d\u540c\u7684\u7ebf\u7a0b\u4e2d\u5e76\u53d1\u5730\u6a21\u62df\u5ba2\u6237\u7aef\u884c\u4e3a\u3002\u8fd9\u662f\u6211\u4eec\u7684\u5e8f\u5217\u5316\u670d\u52a1\u5668\u4e0e\u5ba2\u6237\u7aef\u4ea4\u4e92\u7684\u4fe1\u606f\u8bb0\u5f55\uff1a<\/p>\n

INFO:2017-09-16 14:14:17,763:conn1 connected...\r\nINFO:2017-09-16 14:14:17,763:conn1 sending b'^abc$de^abte$f'\r\nINFO:2017-09-16 14:14:17,763:conn1 received b'b'\r\nINFO:2017-09-16 14:14:17,802:conn1 received b'cdbcuf'\r\nINFO:2017-09-16 14:14:18,764:conn1 sending b'xyz^123'\r\nINFO:2017-09-16 14:14:18,764:conn1 received b'234'\r\nINFO:2017-09-16 14:14:19,764:conn1 sending b'25$^ab0000$abab'\r\nINFO:2017-09-16 14:14:19,765:conn1 received b'36bc1111'\r\nINFO:2017-09-16 14:14:19,965:conn1 disconnecting\r\nINFO:2017-09-16 14:14:19,966:conn2 connected...\r\nINFO:2017-09-16 14:14:19,967:conn2 sending b'^abc$de^abte$f'\r\nINFO:2017-09-16 14:14:19,967:conn2 received b'b'\r\nINFO:2017-09-16 14:14:20,006:conn2 received b'cdbcuf'\r\nINFO:2017-09-16 14:14:20,968:conn2 sending b'xyz^123'\r\nINFO:2017-09-16 14:14:20,969:conn2 received b'234'\r\nINFO:2017-09-16 14:14:21,970:conn2 sending b'25$^ab0000$abab'\r\nINFO:2017-09-16 14:14:21,970:conn2 received b'36bc1111'\r\nINFO:2017-09-16 14:14:22,171:conn2 disconnecting\r\nINFO:2017-09-16 14:14:22,171:conn0 connected...\r\nINFO:2017-09-16 14:14:22,172:conn0 sending b'^abc$de^abte$f'\r\nINFO:2017-09-16 14:14:22,172:conn0 received b'b'\r\nINFO:2017-09-16 14:14:22,210:conn0 received b'cdbcuf'\r\nINFO:2017-09-16 14:14:23,173:conn0 sending b'xyz^123'\r\nINFO:2017-09-16 14:14:23,174:conn0 received b'234'\r\nINFO:2017-09-16 14:14:24,175:conn0 sending b'25$^ab0000$abab'\r\nINFO:2017-09-16 14:14:24,176:conn0 received b'36bc1111'\r\nINFO:2017-09-16 14:14:24,376:conn0 disconnecting\r\n<\/pre>\n

\u8fd9\u91cc\u8981\u6ce8\u610f\u8fde\u63a5\u540d\uff1aconn1\u00a0\u662f\u7b2c\u4e00\u4e2a\u8fde\u63a5\u5230\u670d\u52a1\u5668\u7684\uff0c\u5148\u8ddf\u670d\u52a1\u5668\u4ea4\u4e92\u4e86\u4e00\u6bb5\u65f6\u95f4\u3002\u63a5\u4e0b\u6765\u7684\u8fde\u63a5\u00a0conn2\u2014\u2014 \u5728\u7b2c\u4e00\u4e2a\u65ad\u5f00\u8fde\u63a5\u540e\uff0c\u8fde\u63a5\u5230\u4e86\u670d\u52a1\u5668\uff0c\u7136\u540e\u7b2c\u4e09\u4e2a\u8fde\u63a5\u4e5f\u662f\u4e00\u6837\u3002\u5c31\u50cf\u65e5\u5fd7\u663e\u793a\u7684\u90a3\u6837\uff0c\u6bcf\u4e00\u4e2a\u8fde\u63a5\u8ba9\u670d\u52a1\u5668\u53d8\u5f97\u7e41\u5fd9\uff0c\u6301\u7eed\u4e86\u5927\u7ea6 2.2 \u79d2\u7684\u65f6\u95f4\uff08\u8fd9\u5b9e\u9645\u4e0a\u662f\u4eba\u4e3a\u5730\u5728\u5ba2\u6237\u7aef\u4ee3\u7801\u4e2d\u52a0\u5165\u7684\u5ef6\u8fdf\uff09\uff0c\u5728\u8fd9\u6bb5\u65f6\u95f4\u91cc\u522b\u7684\u5ba2\u6237\u7aef\u90fd\u4e0d\u80fd\u8fde\u63a5\u3002<\/p>\n

\u663e\u7136\uff0c\u8fd9\u4e0d\u662f\u4e00\u4e2a\u53ef\u6269\u5c55\u7684\u7b56\u7565\u3002\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u5ba2\u6237\u7aef\u4e2d\u52a0\u5165\u4e86\u5ef6\u8fdf\uff0c\u8ba9\u670d\u52a1\u5668\u4e0d\u80fd\u5904\u7406\u522b\u7684\u4ea4\u4e92\u52a8\u4f5c\u3002\u4e00\u4e2a\u667a\u80fd\u670d\u52a1\u5668\u5e94\u8be5\u80fd\u5904\u7406\u4e00\u5806\u5ba2\u6237\u7aef\u7684\u8bf7\u6c42\uff0c\u800c\u8fd9\u4e2a\u539f\u59cb\u7684\u670d\u52a1\u5668\u5728\u7ed3\u675f\u8fde\u63a5\u4e4b\u524d\u4e00\u76f4\u7e41\u5fd9\uff08\u6211\u4eec\u5c06\u4f1a\u5728\u4e4b\u540e\u7684\u7ae0\u8282\u4e2d\u770b\u5230\u5982\u4f55\u5b9e\u73b0\u667a\u80fd\u7684\u670d\u52a1\u5668\uff09\u3002\u5c3d\u7ba1\u670d\u52a1\u7aef\u6709\u5ef6\u8fdf\uff0c\u4f46\u8fd9\u4e0d\u4f1a\u8fc7\u5ea6\u5360\u7528 CPU\uff1b\u4f8b\u5982\uff0c\u4ece\u6570\u636e\u5e93\u4e2d\u67e5\u627e\u4fe1\u606f\uff08\u65f6\u95f4\u57fa\u672c\u4e0a\u662f\u82b1\u5728\u8fde\u63a5\u5230\u6570\u636e\u5e93\u670d\u52a1\u5668\u4e0a\uff0c\u6216\u8005\u662f\u82b1\u5728\u786c\u76d8\u4e2d\u7684\u672c\u5730\u6570\u636e\u5e93\uff09\u3002<\/p>\n

\u603b\u7ed3\u53ca\u671f\u671b<\/strong><\/div>\n

\u8fd9\u4e2a\u793a\u4f8b\u670d\u52a1\u5668\u8fbe\u6210\u4e86\u4e24\u4e2a\u9884\u671f\u76ee\u6807\uff1a<\/p>\n

 \t\u9996\u5148\u662f\u4ecb\u7ecd\u4e86\u95ee\u9898\u8303\u7574\u548c\u8d2f\u5f7b\u8be5\u7cfb\u5217\u6587\u7ae0\u7684\u5957\u63a5\u5b57\u7f16\u7a0b\u57fa\u7840\u3002\r\n \t\u5bf9\u4e8e\u5e76\u53d1\u670d\u52a1\u5668\u7f16\u7a0b\u7684\u629b\u7816\u5f15\u7389 \u2014\u2014 \u5c31\u50cf\u4e4b\u524d\u7684\u90e8\u5206\u6240\u8bf4\uff0c\u987a\u5e8f\u670d\u52a1\u5668\u8fd8\u4e0d\u80fd\u5728\u975e\u5e38\u8f7b\u5fae\u7684\u8d1f\u8f7d\u4e0b\u8fdb\u884c\u6269\u5c55\uff0c\u800c\u4e14\u6ca1\u6709\u9ad8\u6548\u7684\u5229\u7528\u8d44\u6e90\u3002\r\n<\/pre>\n

\u5728\u770b\u4e0b\u4e00\u7bc7\u6587\u7ae0\u524d\uff0c\u786e\u4fdd\u4f60\u5df2\u7ecf\u7406\u89e3\u4e86\u8fd9\u91cc\u6240\u8bb2\u7684\u670d\u52a1\u5668\/\u5ba2\u6237\u7aef\u534f\u8bae\uff0c\u8fd8\u6709\u987a\u5e8f\u670d\u52a1\u5668\u7684\u4ee3\u7801\u3002\u6211\u4e4b\u524d\u4ecb\u7ecd\u8fc7\u4e86\u8fd9\u4e2a\u7b80\u5355\u7684\u534f\u8bae\uff1b\u4f8b\u5982\u00a0\u4e32\u884c\u901a\u4fe1\u5206\u5e27\u00a0\u548c\u00a0\u7528\u534f\u7a0b\u6765\u66ff\u4ee3\u72b6\u6001\u673a\u3002\u8981\u5b66\u4e60\u5957\u63a5\u5b57\u7f51\u7edc\u7f16\u7a0b\u7684\u57fa\u7840\uff0cBeej \u7684\u6559\u7a0b\u7528\u6765\u5165\u95e8\u5f88\u4e0d\u9519\uff0c\u4f46\u662f\u8981\u6df1\u5165\u7406\u89e3\u6211\u63a8\u8350\u4f60\u8fd8\u662f\u770b\u672c\u4e66\u3002<\/p>\n

\u5982\u679c\u6709\u4ec0\u4e48\u4e0d\u6e05\u695a\u7684\uff0c\u8bf7\u5728\u8bc4\u8bba\u533a\u4e0b\u8fdb\u884c\u8bc4\u8bba\u6216\u8005\u5411\u6211\u53d1\u9001\u90ae\u4ef6\u3002\u6df1\u5165\u7406\u89e3\u5e76\u53d1\u670d\u52a1\u5668\uff01<\/p>\n


\n
 \t\u6ce81\uff1a\u72b6\u6001\u8f6c\u53d8\u4e2d\u7684 In\/Out \u8bb0\u53f7\u662f\u6307\u00a0Mealy machine\u3002\r\n \t\u6ce82\uff1a\u56de\u5e94\u7684\u662f\u00a0bcdbcuf23436bc\u3002\r\n \t\u6ce83\uff1a\u8fd9\u91cc\u5728\u7ed3\u5c3e\u5904\u6709\u4e00\u70b9\u5c0f\u533a\u522b\uff0c\u52a0\u4e86\u5b57\u7b26\u4e32\u00a00000\u00a0\u2014\u2014 \u670d\u52a1\u5668\u56de\u5e94\u8fd9\u4e2a\u5e8f\u5217\uff0c\u544a\u8bc9\u5ba2\u6237\u7aef\u8ba9\u5176\u65ad\u5f00\u8fde\u63a5\uff1b\u8fd9\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u63e1\u624b\u534f\u8bae\uff0c\u786e\u4fdd\u5ba2\u6237\u7aef\u6709\u8db3\u591f\u7684\u65f6\u95f4\u63a5\u6536\u5230\u670d\u52a1\u5668\u53d1\u9001\u7684\u6240\u6709\u56de\u590d\u3002\r\n<\/pre>\n
\n

via:\u00a0https:\/\/eli.thegreenplace.net\/2017\/concurrent-servers-part-1-introduction\/<\/a><\/p>\n

\u4f5c\u8005\uff1aEli Bendersky<\/a>\u00a0\u8bd1\u8005\uff1aGitFuture<\/a>\u00a0\u6821\u5bf9\uff1awxy<\/a><\/p>\n

\u672c\u6587\u7531\u00a0LCTT<\/a>\u00a0\u539f\u521b\u7f16\u8bd1\uff0cLinux\u4e2d\u56fd<\/a>\u00a0\u8363\u8a89\u63a8\u51fa<\/p>\n

\n

\u539f\u6587\u6765\u81ea\uff1ahttps:\/\/linux.cn\/article-8993-1.html<\/a><\/p>\n

\u672c\u6587\u5730\u5740\uff1a http:\/\/lrxjmw.cn\/introduce-concurrency-server.html<\/a>\u7f16\u8f91\uff1a\u674e\u5e05\uff0c\u5ba1\u6838\u5458\uff1a\u9004\u589e\u5b9d<\/span><\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"

\u5bfc\u8bfb \u8fd9\u662f\u5173\u4e8e\u5e76\u53d1\u7f51\u7edc\u670d\u52a1\u5668\u7f16\u7a0b\u7684\u7b2c\u4e00\u7bc7\u6559\u7a0b\u3002\u6211\u8ba1\u5212\u6d4b\u8bd5\u51e0\u4e2a\u4e3b\u6d41\u7684\u3001\u53ef\u4ee5\u540c\u65f6\u5904\u7406\u591a\u4e2a\u5ba2\u6237\u7aef\u8bf7\u6c42\u7684\u670d\u52a1\u5668\u5e76\u53d1\u6a21\u578b […]<\/p>\n","protected":false},"author":63,"featured_media":86263,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-86249","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\/86249","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\/63"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=86249"}],"version-history":[{"count":23,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/86249\/revisions"}],"predecessor-version":[{"id":86436,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/86249\/revisions\/86436"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/86263"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=86249"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=86249"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=86249"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}