{"id":29789,"date":"2025-04-20T12:56:04","date_gmt":"2025-04-20T04:56:04","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/29789.html"},"modified":"2025-04-20T12:56:04","modified_gmt":"2025-04-20T04:56:04","slug":"%e6%89%8b%e6%8a%8a%e6%89%8b%e5%b8%a6%e4%bd%a0%e5%ae%9e%e7%8e%b0%e5%a4%9a%e7%ba%bf%e7%a8%8b%e6%9c%8d%e5%8a%a1%e5%99%a8","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/29789.html","title":{"rendered":"\u624b\u628a\u624b\u5e26\u4f60\u5b9e\u73b0\u591a\u7ebf\u7a0b\u670d\u52a1\u5668"},"content":{"rendered":"<\/p>\n<h4>\u201c\u4e00\u8bf7\u6c42\u4e00\u7ebf\u7a0b\u201d\u65b9\u5f0f\u5b9e\u73b0\u670d\u52a1\u5668<\/h4>\n<ul>\n<li>\n<ul>\n<li>\u524d\u8a00<\/li>\n<li>socket\u4f7f\u7528\u6d41\u7a0b<\/li>\n<li>\n<ul>\n<li>\u5b9e\u73b0\u601d\u8def<\/li>\n<li>netassist<\/li>\n<li>\u5c0f\u603b\u7ed3<\/li>\n<\/ul>\n<\/li>\n<li>\u7b2c\u4e00\u7248\u670d\u52a1\u5668<\/li>\n<li>\n<ul>\n<li>\u5b9e\u73b0\u601d\u8def<\/li>\n<li>\u51fa\u73b0\u7684\u95ee\u9898<\/li>\n<\/ul>\n<\/li>\n<li>\u7b2c\u4e8c\u7248\u670d\u52a1\u5668<\/li>\n<li>\u7b2c\u4e09\u7248\u670d\u52a1\u5668<\/li>\n<li>\n<ul>\n<li>\u4f7f\u7528\u7ebf\u7a0b<\/li>\n<li>\u89e3\u51b3\u95ee\u9898<\/li>\n<li>\u5173\u4e8efd<\/li>\n<\/ul>\n<\/li>\n<li>\u603b\u7ed3<\/li>\n<li>\u9644\u4ef6<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3>\u524d\u8a00<\/h3>\n<p>\u7531\u4e8e\u8d44\u6e90\u6d88\u8017\u5927\u3001\u7ebf\u7a0b\u7ba1\u7406\u590d\u6742\u3001\u6027\u80fd\u95ee\u9898\u7b49\u539f\u56e0\uff0c\u201c\u4e00\u8bf7\u6c42\u4e00\u7ebf\u7a0b\u201d\uff08\u591a\u7ebf\u7a0b\uff09\u5df2\u7ecf\u88ab\u6dd8\u6c70\uff0c\u73b0\u5728\u6211\u4eec\u591a\u4f7f\u7528select\u3001poll\u3001epoll\u7b49IO\u591a\u8def\u590d\u7528\u6280\u672f\u5b9e\u73b0\u7f51\u7edcIO\u3002\u6211\u4eec\u53ea\u8bb2\u89e3\u5b9e\u73b0\u601d\u8def\uff0c\u5e76\u4e14\u4e3a\u540e\u9762IO\u591a\u8def\u590d\u7528\u6280\u672f\u7684\u6587\u7ae0\u6253\u4e0b\u57fa\u7840\u3002\u5728\u770b\u672c\u6587\u4e4b\u524d\uff0c\u53ef\u4ee5\u5148\u770b\u4e00\u770b \u7f51\u7edcIO\u4ee5\u53casocket\u7f16\u7a0b \u8fd9\u7bc7\u6587\u7ae0\u3002<\/p>\n<h3>socket\u4f7f\u7528\u6d41\u7a0b<\/h3>\n<p>\u5728\u7f51\u7edc\u901a\u4fe1\u4e2d\uff0c\u4e00\u5b9a\u662f\u4f7f\u7528socket\u3002\u4e0b\u9762\u521d\u59cb\u5316socket\u7684\u56fa\u5b9a\u6d41\u7a0b\u3002<\/p>\n<p><span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;netinet\/in.h&gt;<\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;stdio.h&gt;<\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;sys\/socket.h&gt;<\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;errno.h&gt;<\/span><\/span><br \/>\n<span class=\"token macro property\"><span class=\"token directive-hash\">#<\/span><span class=\"token directive keyword\">include<\/span> <span class=\"token string\">&lt;string.h&gt;<\/span><\/span><\/p>\n<p><span class=\"token keyword\">int<\/span> <span class=\"token function\">main<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">{<br \/>\n   <\/span><br \/>\n    <span class=\"token keyword\">int<\/span> sockfd <span class=\"token operator\">=<\/span> <span class=\"token function\">socket<\/span><span class=\"token punctuation\">(<\/span>AF_INET<span class=\"token punctuation\">,<\/span> SOCK_STREAM<span class=\"token punctuation\">,<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">sockaddr_in<\/span> sevaddr<span class=\"token punctuation\">;<\/span><br \/>\n    sevaddr<span class=\"token punctuation\">.<\/span>sin_family <span class=\"token operator\">=<\/span> AF_INET<span class=\"token punctuation\">;<\/span><br \/>\n    sevaddr<span class=\"token punctuation\">.<\/span>sin_addr<span class=\"token punctuation\">.<\/span>s_addr <span class=\"token operator\">=<\/span> <span class=\"token function\">htonl<\/span><span class=\"token punctuation\">(<\/span>INADDR_ANY<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    sevaddr<span class=\"token punctuation\">.<\/span>sin_port <span class=\"token operator\">=<\/span> <span class=\"token function\">htons<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">2000<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token function\">bind<\/span><span class=\"token punctuation\">(<\/span>sockfd<span class=\"token punctuation\">,<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">sockaddr<\/span><span class=\"token operator\">*<\/span><span class=\"token punctuation\">)<\/span><span class=\"token operator\">&amp;<\/span>sevaddr<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">sizeof<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">sockaddr<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">==<\/span> <span class=\"token operator\">&#8211;<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<br \/>\n   <\/span><br \/>\n        <span class=\"token function\">printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">\\&#8221;bind failed: %s\\\\n\\&#8221;<\/span><span class=\"token punctuation\">,<\/span><span class=\"token function\">strerror<\/span><span class=\"token punctuation\">(<\/span>errno<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token keyword\">return<\/span> <span class=\"token operator\">&#8211;<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n    <span class=\"token function\">listen<\/span><span class=\"token punctuation\">(<\/span>sockfd<span class=\"token punctuation\">,<\/span> <span class=\"token number\">10<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token function\">printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">\\&#8221;listen finished\\\\n\\&#8221;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token function\">getchar<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ \u963b\u585e\u5728\u8fd9\u91cc<\/span><br \/>\n    <span class=\"token function\">printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">\\&#8221;exit\\\\n\\&#8221;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">return<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<h4>\u5b9e\u73b0\u601d\u8def<\/h4>\n<p>\u4f7f\u7528socket()\u521b\u5efa\u4e00\u4e2asockfd\uff0c\u7528\u4e8e\u76d1\u542c\u7aef\u53e3\u3002\u7b2c\u4e00\u4e2a\u53c2\u6570AF_INET\u8868\u793a\u4f7f\u7528IPV4\u534f\u8bae\u65cf\uff1b\u7b2c\u4e8c\u4e2a\u53c2\u6570SOCK_STREAM\u521b\u5efa\u6d41\u5f0f\u5957\u63a5\u5b57\u7c7b\u578b\uff0c\u5373TCP\uff1b\u7b2c\u4e09\u4e2a\u53c2\u65700\u5bf9\u4e8e SOCK_STREAM \u7c7b\u578b\u7684\u5957\u63a5\u5b57\uff0c\u901a\u5e38\u8bbe\u7f6e\u4e3a0\uff0c\u8868\u793a\u4f7f\u7528\u9ed8\u8ba4\u7684\u4f20\u8f93\u5c42\u534f\u8bae\u3002<\/p>\n<p><span class=\"token keyword\">int<\/span> sockfd <span class=\"token operator\">=<\/span> <span class=\"token function\">socket<\/span><span class=\"token punctuation\">(<\/span>AF_INET<span class=\"token punctuation\">,<\/span> SOCK_STREAM<span class=\"token punctuation\">,<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>\u4f7f\u7528bind()\u5c06\u521b\u5efa\u7684sockfd\u4e0e\u672c\u673a\u7aef\u53e3\u8fdb\u884c\u7ed1\u5b9a\u3002\u770b\u4e0b\u9762\u7684\u4ee3\u7801\uff0c\u6211\u4eec\u8981\u7ed9\u672c\u5730\u7aef\u53e3\u6307\u5b9a\u901a\u4fe1\u534f\u8bae\u65cf\u3001\u521d\u59cb\u5316\u7f51\u5361\u5730\u5740\u3001\u521d\u59cb\u5316\u7aef\u53e3\u53f7\u3001\u7ed1\u5b9afd\u548c\u672c\u673a\u7aef\u53e3\u3002INADDR_ANY\uff0c\u53730.0.0.0\uff0c\u6307\u672c\u673a\u4efb\u610f\u7f51\u5361\uff1b\u5728\u8ba1\u7b97\u673a\u4e2d\uff0c0~1023\u662f\u9ed8\u8ba4\u7684\u7aef\u53e3\u53f7\uff0c\u6240\u4ee5\u6211\u4eec\u8981\u6307\u5b9a\u7684\u7aef\u53e3\u540e\u987b\u5927\u4e8e1023\uff0c\u8fd9\u91cc\u6211\u4eec\u7ed9\u5b9a\u7684\u7aef\u53e3\u53f7\u662f2000\uff1b\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u4f7f\u7528bind()\u7ed1\u5b9a\uff0c\u82e5\u51fd\u6570\u8fd4\u56de-1\uff0c\u5219\u7ed1\u5b9a\u5931\u8d25\u3002<\/p>\n<p><span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">sockaddr_in<\/span> sevaddr<span class=\"token punctuation\">;<\/span><br \/>\nsevaddr<span class=\"token punctuation\">.<\/span>sin_family <span class=\"token operator\">=<\/span> AF_INET<span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/IPV4<\/span><br \/>\nsevaddr<span class=\"token punctuation\">.<\/span>sin_addr<span class=\"token punctuation\">.<\/span>s_addr <span class=\"token operator\">=<\/span> <span class=\"token function\">htonl<\/span><span class=\"token punctuation\">(<\/span>INADDR_ANY<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/0.0.0.0<\/span><br \/>\nsevaddr<span class=\"token punctuation\">.<\/span>sin_port <span class=\"token operator\">=<\/span> <span class=\"token function\">htons<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">2000<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ 0-1023<\/span><br \/>\n<span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token function\">bind<\/span><span class=\"token punctuation\">(<\/span>sockfd<span class=\"token punctuation\">,<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">sockaddr<\/span><span class=\"token operator\">*<\/span><span class=\"token punctuation\">)<\/span><span class=\"token operator\">&amp;<\/span>sevaddr<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">sizeof<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">sockaddr<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">==<\/span> <span class=\"token operator\">&#8211;<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<br \/>\n   <\/span><br \/>\n       <span class=\"token function\">printf<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">\\&#8221;bind failed: %s\\\\n\\&#8221;<\/span><span class=\"token punctuation\">,<\/span><span class=\"token function\">strerror<\/span><span class=\"token punctuation\">(<\/span>errno<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n       <span class=\"token keyword\">return<\/span> <span class=\"token operator\">&#8211;<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><\/p>\n<p>\u5b8c\u6210\u4e0a\u9762\u7684\u6b65\u9aa4\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u5bf9\u7aef\u53e3\u8fdb\u884c\u76d1\u542c\u4e86\u3002<\/p>\n<p><span class=\"token function\">listen<\/span><span class=\"token punctuation\">(<\/span>sockfd<span class=\"token punctuation\">,<\/span> <span class=\"token number\">10<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>\u6211\u4eec\u53ef\u4ee5\u5148\u5bf9\u7a0b\u5e8f\u7f16\u8bd1\u8fd0\u884c\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u5230\u53d7getchar()\u7684\u5f71\u54cd\uff0c\u7a0b\u5e8f\u5904\u4e8e\u963b\u585e\u72b6\u6001\u3002 <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250420045602-68047e62392f1.png\" alt=\"p1\"> \u6211\u4eec\u6572\u4e00\u4e0b\u56de\u8f66\uff0c\u7a0b\u5e8f\u9000\u51fa\u3002 <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250420045602-68047e625c664.png\" alt=\"p\"> \u73b0\u5728\uff0c\u6211\u4eec\u518d\u6253\u5f00\u4e00\u4e2a\u65b0\u7684\u7ec8\u7aef\uff0c\u8f93\u5165\u547d\u4ee4netstat -anop | grep 2000\u67e5\u770b\u7aef\u53e32000\u7684\u4f7f\u7528\u60c5\u51b5\u3002\u6211\u4eec\u53ef\u4ee5\u770b\u5230\u7aef\u53e32000\u5df2\u7ecf\u88ab\u4f7f\u7528\u3002 <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250420045602-68047e6280eab.png\" alt=\"p2\"> \u6216\u8005\uff0c\u6211\u4eec\u53ef\u4ee5\u5728\u7b2c\u4e8c\u4e2a\u7ec8\u7aef\u4e2d\u8fd0\u884c\u8be5\u7a0b\u5e8f\u3002\u7f16\u8bd1\u5668\u8fd4\u56debind failed: Address already in use\uff0c\u5f88\u597d\uff0c\u8fd9\u8868\u660e\u7aef\u53e3\u5df2\u7ecf\u88ab\u5360\u7528\uff0c\u8fd9\u662f\u6211\u4eec\u60f3\u8981\u770b\u5230\u7684\u7ed3\u679c\u3002 <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250420045602-68047e62ad84d.png\" alt=\"p3\"><\/p>\n<h4>netassist<\/h4>\n<p>\u5728\u8fd9\u91cc\uff0c\u5411\u5927\u5bb6\u5b89\u5229netassist\uff08\u7f51\u7edc\u8c03\u8bd5\u52a9\u624b\uff09\uff0c\u4f5c\u4e3a\u6211\u4eec\u7684\u5ba2\u6237\u7aef\u3002\u8fd9\u91cc\u6211\u76f4\u63a5\u4f7f\u7528127.0.0.1\uff08\u672c\u5730\u56de\u73af\u5730\u5740\uff09\u4f5c\u4e3a\u6211\u7684\u8fdc\u7a0b\u4e3b\u673a\u5730\u5740\u3002 <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250420045602-68047e62d0316.png\" alt=\"p4\"> \u73b0\u5728\uff0c\u6211\u4eec\u8fde\u63a5\u5df2\u7ecf\u8fd0\u884c\u7684\u7a0b\u5e8f\u3002\u53ef\u4ee5\u770b\u5230\uff0c\u8fde\u63a5\u6210\u529f\u4e86\uff01 <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250420045603-68047e632be37.png\" alt=\"p5\"> \u56e0\u4e3alisten\u6267\u884c\u6210\u529f\u5e76\u4e14\u5ba2\u6237\u7aef\u5df2\u7ecf\u8fde\u63a5\uff0c\u73b0\u5728\u6211\u4eec\u901a\u8fc7netstat\u67e5\u770b\u7aef\u53e3\u72b6\u6001\u3002\u53ef\u4ee5\u770b\u5230\uff0c\u4ea7\u751f\u4e86\u4e00\u4e2a\u65b0\u7684\u8fde\u63a5\u72b6\u6001\u3002 <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250420045603-68047e63af05e.png\" alt=\"p6\"> \u65e2\u7136\u5df2\u7ecf\u8fde\u63a5\u4e0a\u4e86\uff0c\u90a3\u4e48\u662f\u5426\u53ef\u4ee5\u53d1\u6570\u636e\uff1f\u5f53\u7136\u53ef\u4ee5\u4e86\uff01 \u70b9\u51fb\u201c\u53d1\u9001\u201d\uff0c\u770b\u5230netassist\u7684\u53f3\u4e0b\u89d2\u7684TX\u4ece0\u53d8\u4e3a20\uff0c\u8868\u793a\u53d1\u9001\u4e8620\u5b57\u8282\u7684\u6570\u636e\u5230server\u7aef\u3002\u53ef\u662f\uff0c\u6211\u4eec\u5728server\u7aef\u5e76\u6ca1\u6709\u770b\u5230\u53d1\u9001\u7684\u6570\u636e\uff0c\u53ef\u4ee5\u786e\u5b9a\u7684\u662fserver\u5df2\u7ecf\u63a5\u6536\u5230\u4e86\u4fe1\u606f\u3002\u56e0\u4e3a\uff0cserver\u7aef\u6682\u65f6\u4e0d\u80fd\u5c06\u63a5\u6536\u5230\u7684\u6570\u636e\u6253\u5370\u51fa\u6765\u3002 <\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.7k\u6b21\uff0c\u70b9\u8d5e40\u6b21\uff0c\u6536\u85cf29\u6b21\u3002\u7531\u4e8e\u8d44\u6e90\u6d88\u8017\u5927\u3001\u7ebf\u7a0b\u7ba1\u7406\u590d\u6742\u3001\u6027\u80fd\u95ee\u9898\u7b49\u539f\u56e0\uff0c\u201c\u4e00\u8bf7\u6c42\u4e00\u7ebf\u7a0b\u201d\uff08\u591a\u7ebf\u7a0b\uff09\u5df2\u7ecf\u88ab\u6dd8\u6c70\uff0c\u73b0\u5728\u6211\u4eec\u591a\u4f7f\u7528select\u3001poll\u3001epoll\u7b49IO\u591a\u8def\u590d\u7528\u6280\u672f\u5b9e\u73b0\u7f51\u7edcIO\u3002\u6211\u4eec\u53ea\u8bb2\u89e3\u5b9e\u73b0\u601d\u8def\uff0c\u5e76\u4e14\u4e3a\u540e\u9762IO\u591a\u8def\u590d\u7528\u6280\u672f\u7684\u6587\u7ae0\u6253\u4e0b\u57fa\u7840\u3002\u5728\u770b\u672c\u6587\u4e4b\u524d\uff0c\u53ef\u4ee5\u5148\u770b\u4e00\u770b\u7f51\u7edcIO\u4ee5\u53casocket\u7f16\u7a0b\u8fd9\u7bc7\u6587\u7ae0\u3002\u7aef\u53e3\u88ab\u7ed1\u5b9a\u540e\uff0c\u4e0d\u80fd\u518d\u6b21\u7ed1\u5b9a\u3002\u6267\u884clisten\uff0c\u53ef\u4ee5\u901a\u8fc7netstat\u67e5\u770bIO\u72b6\u6001\u3002\u8fdb\u5165listen\u53ef\u4ee5\u88ab\u8fde\u63a5\uff0c\u5e76\u4e14\u4ea7\u751f\u65b0\u8fde\u63a5\u72b6\u6001\u3002io\u4e0etcp\u8fde\u63a5\u3002P6\u4e2d\uff0c\u6bcf\u751f\u6210\u4e00\u6761\u4fe1\u606f\u4ee3\u8868\u4e2d\u4e00\u4e2aIO\u3002_\u670d\u52a1\u5668\u591a\u7ebf\u7a0b<\/p>\n","protected":false},"author":2,"featured_media":29782,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[43,78],"topic":[],"class_list":["post-29789","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-43","tag-78"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u624b\u628a\u624b\u5e26\u4f60\u5b9e\u73b0\u591a\u7ebf\u7a0b\u670d\u52a1\u5668 - \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\/29789.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u624b\u628a\u624b\u5e26\u4f60\u5b9e\u73b0\u591a\u7ebf\u7a0b\u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.7k\u6b21\uff0c\u70b9\u8d5e40\u6b21\uff0c\u6536\u85cf29\u6b21\u3002\u7531\u4e8e\u8d44\u6e90\u6d88\u8017\u5927\u3001\u7ebf\u7a0b\u7ba1\u7406\u590d\u6742\u3001\u6027\u80fd\u95ee\u9898\u7b49\u539f\u56e0\uff0c\u201c\u4e00\u8bf7\u6c42\u4e00\u7ebf\u7a0b\u201d\uff08\u591a\u7ebf\u7a0b\uff09\u5df2\u7ecf\u88ab\u6dd8\u6c70\uff0c\u73b0\u5728\u6211\u4eec\u591a\u4f7f\u7528select\u3001poll\u3001epoll\u7b49IO\u591a\u8def\u590d\u7528\u6280\u672f\u5b9e\u73b0\u7f51\u7edcIO\u3002\u6211\u4eec\u53ea\u8bb2\u89e3\u5b9e\u73b0\u601d\u8def\uff0c\u5e76\u4e14\u4e3a\u540e\u9762IO\u591a\u8def\u590d\u7528\u6280\u672f\u7684\u6587\u7ae0\u6253\u4e0b\u57fa\u7840\u3002\u5728\u770b\u672c\u6587\u4e4b\u524d\uff0c\u53ef\u4ee5\u5148\u770b\u4e00\u770b\u7f51\u7edcIO\u4ee5\u53casocket\u7f16\u7a0b\u8fd9\u7bc7\u6587\u7ae0\u3002\u7aef\u53e3\u88ab\u7ed1\u5b9a\u540e\uff0c\u4e0d\u80fd\u518d\u6b21\u7ed1\u5b9a\u3002\u6267\u884clisten\uff0c\u53ef\u4ee5\u901a\u8fc7netstat\u67e5\u770bIO\u72b6\u6001\u3002\u8fdb\u5165listen\u53ef\u4ee5\u88ab\u8fde\u63a5\uff0c\u5e76\u4e14\u4ea7\u751f\u65b0\u8fde\u63a5\u72b6\u6001\u3002io\u4e0etcp\u8fde\u63a5\u3002P6\u4e2d\uff0c\u6bcf\u751f\u6210\u4e00\u6761\u4fe1\u606f\u4ee3\u8868\u4e2d\u4e00\u4e2aIO\u3002_\u670d\u52a1\u5668\u591a\u7ebf\u7a0b\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/29789.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-04-20T04:56:04+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250420045602-68047e62392f1.png\" \/>\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=\"1 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/29789.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/29789.html\",\"name\":\"\u624b\u628a\u624b\u5e26\u4f60\u5b9e\u73b0\u591a\u7ebf\u7a0b\u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-04-20T04:56:04+00:00\",\"dateModified\":\"2025-04-20T04:56:04+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/29789.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/29789.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/29789.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u624b\u628a\u624b\u5e26\u4f60\u5b9e\u73b0\u591a\u7ebf\u7a0b\u670d\u52a1\u5668\"}]},{\"@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":"\u624b\u628a\u624b\u5e26\u4f60\u5b9e\u73b0\u591a\u7ebf\u7a0b\u670d\u52a1\u5668 - \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\/29789.html","og_locale":"zh_CN","og_type":"article","og_title":"\u624b\u628a\u624b\u5e26\u4f60\u5b9e\u73b0\u591a\u7ebf\u7a0b\u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.7k\u6b21\uff0c\u70b9\u8d5e40\u6b21\uff0c\u6536\u85cf29\u6b21\u3002\u7531\u4e8e\u8d44\u6e90\u6d88\u8017\u5927\u3001\u7ebf\u7a0b\u7ba1\u7406\u590d\u6742\u3001\u6027\u80fd\u95ee\u9898\u7b49\u539f\u56e0\uff0c\u201c\u4e00\u8bf7\u6c42\u4e00\u7ebf\u7a0b\u201d\uff08\u591a\u7ebf\u7a0b\uff09\u5df2\u7ecf\u88ab\u6dd8\u6c70\uff0c\u73b0\u5728\u6211\u4eec\u591a\u4f7f\u7528select\u3001poll\u3001epoll\u7b49IO\u591a\u8def\u590d\u7528\u6280\u672f\u5b9e\u73b0\u7f51\u7edcIO\u3002\u6211\u4eec\u53ea\u8bb2\u89e3\u5b9e\u73b0\u601d\u8def\uff0c\u5e76\u4e14\u4e3a\u540e\u9762IO\u591a\u8def\u590d\u7528\u6280\u672f\u7684\u6587\u7ae0\u6253\u4e0b\u57fa\u7840\u3002\u5728\u770b\u672c\u6587\u4e4b\u524d\uff0c\u53ef\u4ee5\u5148\u770b\u4e00\u770b\u7f51\u7edcIO\u4ee5\u53casocket\u7f16\u7a0b\u8fd9\u7bc7\u6587\u7ae0\u3002\u7aef\u53e3\u88ab\u7ed1\u5b9a\u540e\uff0c\u4e0d\u80fd\u518d\u6b21\u7ed1\u5b9a\u3002\u6267\u884clisten\uff0c\u53ef\u4ee5\u901a\u8fc7netstat\u67e5\u770bIO\u72b6\u6001\u3002\u8fdb\u5165listen\u53ef\u4ee5\u88ab\u8fde\u63a5\uff0c\u5e76\u4e14\u4ea7\u751f\u65b0\u8fde\u63a5\u72b6\u6001\u3002io\u4e0etcp\u8fde\u63a5\u3002P6\u4e2d\uff0c\u6bcf\u751f\u6210\u4e00\u6761\u4fe1\u606f\u4ee3\u8868\u4e2d\u4e00\u4e2aIO\u3002_\u670d\u52a1\u5668\u591a\u7ebf\u7a0b","og_url":"https:\/\/www.wsisp.com\/helps\/29789.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-04-20T04:56:04+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250420045602-68047e62392f1.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"1 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/29789.html","url":"https:\/\/www.wsisp.com\/helps\/29789.html","name":"\u624b\u628a\u624b\u5e26\u4f60\u5b9e\u73b0\u591a\u7ebf\u7a0b\u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-04-20T04:56:04+00:00","dateModified":"2025-04-20T04:56:04+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/29789.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/29789.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/29789.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u624b\u628a\u624b\u5e26\u4f60\u5b9e\u73b0\u591a\u7ebf\u7a0b\u670d\u52a1\u5668"}]},{"@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\/29789","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=29789"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/29789\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/29782"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=29789"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=29789"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=29789"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=29789"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}