{"id":38240,"date":"2025-05-20T04:26:01","date_gmt":"2025-05-19T20:26:01","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/38240.html"},"modified":"2025-05-20T04:26:01","modified_gmt":"2025-05-19T20:26:01","slug":"%e3%80%90linux%e3%80%91socket%e7%bd%91%e7%bb%9c%e7%bc%96%e7%a8%8b%e5%9f%ba%e7%a1%80","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/38240.html","title":{"rendered":"\u3010Linux\u3011socket\u7f51\u7edc\u7f16\u7a0b\u57fa\u7840"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250519202559-682b93d7de18e.jpg\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u4e2a\u4eba\u4e3b\u9875~<\/p>\n<hr \/>\n<h4>socket\u7f51\u7edc\u7f16\u7a0b\u57fa\u7840<\/h4>\n<ul>\n<li>\u4e00\u3001IP\u5730\u5740<\/li>\n<li>\n<ul>\n<li>1\u3001\u6982\u5ff5<\/li>\n<li>2\u3001\u6e90IP\u5730\u5740\u548c\u76ee\u7684IP\u5730\u5740<\/li>\n<\/ul>\n<\/li>\n<li>\u4e8c\u3001\u7aef\u53e3\u53f7<\/li>\n<li>\n<ul>\n<li>1\u3001\u6982\u5ff5<\/li>\n<li>2\u3001\u6e90\u7aef\u53e3\u53f7\u548c\u76ee\u7684\u7aef\u53e3\u53f7<\/li>\n<\/ul>\n<\/li>\n<li>\u4e09\u3001TCP\u548cUDP\u534f\u8bae<\/li>\n<li>\u56db\u3001\u7f51\u7edc\u5b57\u8282\u5e8f<\/li>\n<li>\u4e94\u3001\u7f51\u7edc\u901a\u4fe1\u7684\u672c\u8d28<\/li>\n<li>\u516d\u3001\u5168\u9762\u8ba4\u8bc6\u7f51\u7edc\u901a\u4fe1<\/li>\n<li>\u4e03\u3001socket\u7f16\u7a0b\u57fa\u7840<\/li>\n<li>\n<ul>\n<li>1\u3001\u8c03\u7528\u63a5\u53e3<\/li>\n<li>\n<ul>\n<li>&#xff08;\u4e00&#xff09;\u521b\u5efa\u63cf\u8ff0\u7b26<\/li>\n<li>&#xff08;\u4e8c&#xff09;\u7ed1\u5b9a\u7aef\u53e3\u53f7<\/li>\n<li>&#xff08;\u4e09&#xff09;\u76d1\u542c\u5957\u63a5\u5b57<\/li>\n<li>&#xff08;\u56db&#xff09;\u63a5\u6536\u8bf7\u6c42<\/li>\n<li>&#xff08;\u4e94&#xff09;\u5efa\u7acb\u8fde\u63a5<\/li>\n<\/ul>\n<\/li>\n<li>2\u3001sockaddr\u7684\u7ed3\u6784<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h2>\u4e00\u3001IP\u5730\u5740<\/h2>\n<h3>1\u3001\u6982\u5ff5<\/h3>\n<p>IP\u5730\u5740\u662f\u5728IP\u534f\u8bae\u4e2d&#xff0c;\u7528\u6765\u6807\u8bc6\u7f51\u7edc\u4e2d\u4e0d\u540c\u4e3b\u673a\u7684\u5730\u5740&#xff0c;\u5b83\u6709\u4e24\u4e2a\u7248\u672c&#xff0c;\u4e00\u4e2a\u662fIPv4&#xff0c;\u4e00\u4e2a\u662fIPv6&#xff0c;IPv4\u662f\u4e00\u4e2a32\u4f4d4\u5b57\u8282\u7684\u6570\u5b57&#xff0c;\u901a\u5e38\u4f7f\u7528\u70b9\u5206\u5341\u8fdb\u5236\u7684\u5b57\u7b26\u4e32\u8868\u793aIP\u5730\u5740&#xff0c;\u4f8b\u5982192.168.1.1&#xff0c;IPv6\u662f\u4e00\u4e2a108\u4f4d16\u5b57\u8282\u7684\u6570\u5b57&#xff0c;\u4e00\u822c\u6765\u8bf4&#xff0c;\u73b0\u5728\u5728\u4e16\u754c\u4e0a\u4f7f\u7528\u89c4\u6a21\u6700\u5927\u7684\u5c31\u662fIPv4&#xff0c;\u4f46\u662f\u56e0\u4e3a4\u5b57\u8282\u80fd\u8868\u793a\u7684\u6570\u5b57\u53ea\u6709\u4e0d\u523043\u4ebf&#xff0c;\u968f\u7740\u65f6\u4ee3\u7684\u8fdb\u6b65&#xff0c;\u5165\u7f51\u8bbe\u5907\u4ece\u7535\u8111\u548c\u624b\u673a\u9010\u6e10\u53d8\u6210\u4e86\u9664\u4e86\u5b83\u4eec\u4ee5\u5916\u5176\u4ed6\u7684\u4f8b\u5982\u7a7a\u8c03\u3001\u6d17\u8863\u673a\u3001\u51b0\u7bb1\u3001\u667a\u80fd\u97f3\u7bb1\u3001\u667a\u80fd\u95e8\u9501\u3001\u7535\u89c6\u7b49\u7b49&#xff0c;\u6bcf\u4e00\u4e2a\u667a\u80fd\u8bbe\u5907\u90fd\u8981\u6709\u4e00\u4e2a\u81ea\u5df1\u7684IP\u5730\u5740&#xff0c;\u6240\u4ee5\u6211\u4eec\u56fd\u5bb6\u5bf9\u4e8eIPv6\u7684\u5e03\u7f6e\u662f\u6218\u7565\u6027\u7684&#xff0c;\u6211\u56fd\u662f\u4e16\u754c\u4e0a\u5bf9\u4e8eIPv6\u666e\u53ca\u6700\u5e7f\u7684\u56fd\u5bb6&#xff0c;\u5f53\u7136\u6211\u4eec\u73b0\u5728\u5305\u62ec\u672c\u6587\u540e\u9762\u4e00\u822c\u63d0\u5230IP\u534f\u8bae\u4e00\u822c\u90fd\u662fIPv4<\/p>\n<h3>2\u3001\u6e90IP\u5730\u5740\u548c\u76ee\u7684IP\u5730\u5740<\/h3>\n<ul>\n<li>\u6e90 IP \u5730\u5740&#xff1a;\u662f\u6307\u5728\u7f51\u7edc\u901a\u4fe1\u4e2d&#xff0c;\u53d1\u9001\u6570\u636e\u7684\u8bbe\u5907\u6240\u4f7f\u7528\u7684 IP \u5730\u5740&#xff0c;\u5b83\u6807\u8bc6\u4e86\u6570\u636e\u7684\u53d1\u9001\u7aef&#xff0c;\u7528\u4e8e\u8ba9\u63a5\u6536\u65b9\u77e5\u9053\u6570\u636e\u662f\u4ece\u54ea\u91cc\u6765\u7684&#xff0c;\u5c31\u5982\u540c\u4fe1\u4ef6\u4e0a\u7684\u5bc4\u4ef6\u4eba\u5730\u5740\u4e00\u6837<\/li>\n<li>\u76ee\u7684 IP \u5730\u5740&#xff1a;\u662f\u6307\u6570\u636e\u8981\u53d1\u9001\u5230\u7684\u76ee\u6807\u8bbe\u5907\u7684 IP \u5730\u5740&#xff0c;\u5b83\u6807\u8bc6\u4e86\u6570\u636e\u7684\u63a5\u6536\u7aef&#xff0c;\u6307\u793a\u6570\u636e\u5e94\u8be5\u88ab\u53d1\u9001\u5230\u54ea\u91cc&#xff0c;\u7c7b\u4f3c\u4e8e\u4fe1\u4ef6\u4e0a\u7684\u6536\u4ef6\u4eba\u5730\u5740<\/li>\n<\/ul>\n<p>\u6e90IP\u5730\u5740\u548c\u76ee\u7684IP\u5730\u5740\u5171\u540c\u6784\u6210\u4e86\u7f51\u7edc\u901a\u4fe1\u7684\u57fa\u7840\u5bfb\u5740\u4f53\u7cfb&#xff0c;\u5b83\u4eec\u786e\u4fdd\u4e86\u6570\u636e\u5728\u590d\u6742\u7684\u7f51\u7edc\u73af\u5883\u4e2d\u80fd\u591f\u51c6\u786e\u3001\u9ad8\u6548\u5730\u4f20\u8f93&#xff0c;\u5728\u6570\u636e\u53d1\u9001\u524d&#xff0c;\u53d1\u9001\u8bbe\u5907\u4f1a\u5728 IP \u6570\u636e\u5305\u7684\u5934\u90e8\u5c01\u88c5\u597d\u6e90 IP \u5730\u5740\u548c\u76ee\u7684 IP \u5730\u5740&#xff0c;\u7136\u540e\u6570\u636e\u5728\u7f51\u7edc\u4e2d\u4f20\u8f93\u65f6&#xff0c;\u8def\u7531\u5668\u7b49\u7f51\u7edc\u8bbe\u5907\u4f1a\u6839\u636e\u8fd9\u4e9b\u5730\u5740\u4fe1\u606f\u8fdb\u884c\u8def\u7531\u9009\u62e9\u548c\u6570\u636e\u8f6c\u53d1&#xff0c;\u76f4\u5230\u6570\u636e\u5230\u8fbe\u76ee\u7684\u8bbe\u5907&#xff0c;\u6574\u4e2a\u7f51\u7edc\u901a\u4fe1\u8fc7\u7a0b\u5c31\u662f\u56f4\u7ed5\u7740\u6e90 IP \u5730\u5740\u548c\u76ee\u7684 IP \u5730\u5740\u8fdb\u884c\u7684\u4e00\u7cfb\u5217\u6570\u636e\u5c01\u88c5\u3001\u4f20\u8f93\u3001\u8def\u7531\u548c\u4ea4\u4ed8\u7684\u64cd\u4f5c<\/p>\n<p>IP\u5730\u5740\u7528\u4e8e\u4e0d\u540c\u7f51\u7edc\u4e4b\u95f4\u5bfb\u5740&#xff0c;MAC\u5730\u5740\u7528\u4e8e\u540c\u5c40\u57df\u7f51\u4f20\u8f93<\/p>\n<h2>\u4e8c\u3001\u7aef\u53e3\u53f7<\/h2>\n<h3>1\u3001\u6982\u5ff5<\/h3>\n<p>\u7aef\u53e3\u53f7\u662f\u4f20\u8f93\u5c42\u534f\u8bae\u7684\u5185\u5bb9<\/p>\n<p>\u7aef\u53e3\u53f7\u662f\u4e00\u4e2a16\u4f4d2\u5b57\u8282\u7684\u6570\u5b57&#xff0c;\u7528\u6765\u6807\u8bc6\u4e00\u4e2a\u8fdb\u7a0b\u5e76\u64cd\u4f5c\u7cfb\u7edf\u5f53\u524d\u7684\u8fd9\u4e2a\u6570\u636e\u8981\u4ea4\u7ed9\u54ea\u4e2a\u8fdb\u7a0b\u5904\u7406<\/p>\n<p>IP\u5730\u5740&#043;\u7aef\u53e3\u53f7\u80fd\u591f\u6807\u8bc6\u7f51\u7edc\u4e0a\u7684\u67d0\u4e00\u53f0\u4e3b\u673a\u7684\u67d0\u4e00\u8fdb\u7a0b<\/p>\n<p>\u4e00\u4e2a\u7aef\u53e3\u53f7\u53ea\u80fd\u88ab\u4e00\u4e2a\u8fdb\u7a0b\u5360\u7528&#xff0c;\u4f46\u4e00\u4e2a\u8fdb\u7a0b\u53ef\u4ee5\u7ed1\u5b9a\u591a\u4e2a\u7aef\u53e3\u53f7<\/p>\n<p>\u8fd9\u91cc\u6211\u4eec\u6709\u95ee\u9898\u4e86&#xff0c;\u4e3b\u64ad\u4e3b\u64ad&#xff0c;\u4e3a\u4ec0\u4e48\u7aef\u53e3\u53f7\u548c\u8fdb\u7a0bpid\u90fd\u80fd\u6807\u8bc6\u4e00\u4e2a\u8fdb\u7a0b&#xff0c;\u90a3\u4ed6\u4eec\u5206\u51fa\u6765\u5e72\u5565\u5462&#xff1f; \u5176\u5b9e&#xff0c;\u7aef\u53e3\u53f7\u4e0e\u8fdb\u7a0bpid&#xff0c;\u524d\u8005\u7528\u6765\u8868\u793a\u7f51\u7edc\u5185\u5bb9&#xff0c;\u540e\u8005\u7528\u6765\u8868\u793a\u7cfb\u7edf\u5185\u5bb9&#xff0c;\u5c06\u7f51\u7edc\u548c\u7cfb\u7edf\u7684\u5185\u5bb9\u8fdb\u884c\u89e3\u8026\u5408&#xff0c;\u5728\u4e00\u65b9\u51fa\u73b0\u95ee\u9898\u7684\u65f6\u5019\u4e0d\u5f71\u54cd\u53e6\u4e00\u65b9<\/p>\n<h3>2\u3001\u6e90\u7aef\u53e3\u53f7\u548c\u76ee\u7684\u7aef\u53e3\u53f7<\/h3>\n<ul>\n<li>\u6e90\u7aef\u53e3\u53f7&#xff1a;\u662f\u5728\u7f51\u7edc\u901a\u4fe1\u4e2d&#xff0c;\u53d1\u9001\u6570\u636e\u7684\u5e94\u7528\u7a0b\u5e8f\u6216\u8fdb\u7a0b\u6240\u4f7f\u7528\u7684\u7aef\u53e3\u53f7&#xff0c;\u5b83\u6807\u8bc6\u4e86\u6570\u636e\u7684\u53d1\u9001\u7aef\u5e94\u7528\u7a0b\u5e8f\u6216\u8fdb\u7a0b&#xff0c;\u4f7f\u5f97\u63a5\u6536\u65b9\u80fd\u591f\u77e5\u9053\u6570\u636e\u662f\u7531\u53d1\u9001\u65b9\u8bbe\u5907\u4e0a\u7684\u54ea\u4e2a\u5e94\u7528\u7a0b\u5e8f\u6216\u8fdb\u7a0b\u53d1\u51fa\u7684<\/li>\n<li>\u76ee\u7684\u7aef\u53e3\u53f7&#xff1a;\u662f\u6570\u636e\u8981\u53d1\u9001\u5230\u7684\u76ee\u6807\u5e94\u7528\u7a0b\u5e8f\u6216\u8fdb\u7a0b\u7684\u7aef\u53e3\u53f7&#xff0c;\u5b83\u6307\u5b9a\u4e86\u6570\u636e\u5e94\u8be5\u88ab\u4ea4\u4ed8\u5230\u76ee\u6807\u8bbe\u5907\u4e0a\u7684\u54ea\u4e2a\u5e94\u7528\u7a0b\u5e8f\u6216\u8fdb\u7a0b&#xff0c;\u7c7b\u4f3c\u4e8e\u5728\u4e00\u4e2a\u5efa\u7b51\u7269\u4e2d\u6307\u5b9a\u5177\u4f53\u7684\u623f\u95f4\u53f7<\/li>\n<\/ul>\n<p>\u5728\u7f51\u7edc\u901a\u4fe1\u4e2d&#xff0c;\u6e90\u7aef\u53e3\u53f7\u548c\u76ee\u7684\u7aef\u53e3\u53f7\u4e0e\u6e90 IP \u5730\u5740\u3001\u76ee\u7684 IP \u5730\u5740\u4ee5\u53ca\u4f20\u8f93\u5c42\u534f\u8bae&#xff08;TCP \u6216 UDP&#xff09;\u5171\u540c\u6784\u6210\u4e86\u5b8c\u6574\u7684\u901a\u4fe1\u6807\u8bc6&#xff0c;IP\u5730\u5740\u80fd\u8868\u793a\u552f\u4e00\u7684\u4e3b\u673a&#xff0c;\u7aef\u53e3\u53f7\u80fd\u6807\u8bc6\u8be5\u4e3b\u673a\u4e0a\u7684\u552f\u4e00\u4e00\u4e2a\u8fdb\u7a0b&#xff0c;\u6240\u4ee5\u4ed6\u4eec\u7ed3\u5408\u5c31\u53ef\u4ee5\u627e\u5230\u6211\u4eec\u6307\u5b9a\u7684\u8fdb\u7a0b&#xff0c;\u5f53\u5e94\u7528\u7a0b\u5e8f\u8981\u53d1\u9001\u6570\u636e\u65f6&#xff0c;\u4f1a\u5728\u4f20\u8f93\u5c42\u5c06\u6570\u636e\u5c01\u88c5\u6210\u6570\u636e\u5305&#xff0c;\u5e76\u5728\u6570\u636e\u5305\u4e2d\u6dfb\u52a0\u6e90\u7aef\u53e3\u53f7\u3001\u76ee\u7684\u7aef\u53e3\u53f7\u3001\u6e90 IP \u5730\u5740\u548c\u76ee\u7684 IP \u5730\u5740\u7b49\u4fe1\u606f&#xff0c;\u5728\u6570\u636e\u4f20\u8f93\u8fc7\u7a0b\u4e2d&#xff0c;\u7f51\u7edc\u8bbe\u5907\u4f1a\u6839\u636e\u8fd9\u4e9b\u4fe1\u606f\u8fdb\u884c\u6570\u636e\u7684\u8def\u7531\u548c\u8f6c\u53d1&#xff0c;\u786e\u4fdd\u6570\u636e\u80fd\u591f\u4ece\u6e90\u5e94\u7528\u7a0b\u5e8f\u6216\u8fdb\u7a0b\u51c6\u786e\u5730\u4f20\u8f93\u5230\u76ee\u6807\u5e94\u7528\u7a0b\u5e8f\u6216\u8fdb\u7a0b<\/p>\n<h2>\u4e09\u3001TCP\u548cUDP\u534f\u8bae<\/h2>\n<ul>\n<li>\u57fa\u672c\u6982\u5ff5\n<ul>\n<li>TCP&#xff1a;\u662f\u4e00\u79cd\u9762\u5411\u8fde\u63a5\u7684\u3001\u53ef\u9760\u7684\u3001\u57fa\u4e8e\u5b57\u8282\u6d41\u7684\u4f20\u8f93\u5c42\u901a\u4fe1\u534f\u8bae&#xff0c;\u5b83\u5c31\u50cf\u6253\u7535\u8bdd&#xff0c;\u5728\u6570\u636e\u4f20\u8f93\u524d\u9700\u8981\u5148\u5efa\u7acb\u8fde\u63a5&#xff0c;\u4f20\u8f93\u8fc7\u7a0b\u4e2d\u4f1a\u5bf9\u6570\u636e\u8fdb\u884c\u786e\u8ba4\u3001\u91cd\u4f20\u7b49\u64cd\u4f5c\u4ee5\u786e\u4fdd\u6570\u636e\u7684\u5b8c\u6574\u6027\u548c\u51c6\u786e\u6027&#xff0c;\u4f20\u8f93\u7ed3\u675f\u540e\u8fd8\u9700\u8981\u5173\u95ed\u8fde\u63a5<\/li>\n<li>UDP&#xff1a;\u662f\u4e00\u79cd\u65e0\u8fde\u63a5\u7684\u3001\u4e0d\u53ef\u9760\u7684\u4f20\u8f93\u5c42\u534f\u8bae&#xff0c;\u5b83\u7c7b\u4f3c\u5199\u4fe1&#xff0c;\u4e0d\u9700\u8981\u4e8b\u5148\u5efa\u7acb\u8fde\u63a5\u5c31\u53ef\u4ee5\u76f4\u63a5\u53d1\u9001\u6570\u636e&#xff0c;\u4e5f\u4e0d\u4f1a\u5bf9\u6570\u636e\u8fdb\u884c\u590d\u6742\u7684\u786e\u8ba4\u548c\u91cd\u4f20\u64cd\u4f5c&#xff0c;\u6570\u636e\u53d1\u9001\u51fa\u53bb\u540e\u5c31\u4e0d\u7ba1\u4e86&#xff0c;\u4e0d\u4fdd\u8bc1\u6570\u636e\u4e00\u5b9a\u80fd\u5230\u8fbe\u76ee\u7684\u5730\u6216\u6309\u987a\u5e8f\u5230\u8fbe<\/li>\n<\/ul>\n<\/li>\n<li>\u7279\u70b9\n<ul>\n<li>TCP\n<ul>\n<li>\u9762\u5411\u8fde\u63a5&#xff1a;\u5728\u6570\u636e\u4f20\u8f93\u4e4b\u524d&#xff0c;\u5fc5\u987b\u5148\u5efa\u7acb\u8fde\u63a5&#xff0c;\u901a\u8fc7\u4e09\u6b21\u63e1\u624b\u6765\u786e\u5b9a\u53cc\u65b9\u7684\u8fde\u63a5\u72b6\u6001&#xff0c;\u786e\u4fdd\u6570\u636e\u4f20\u8f93\u7684\u53ef\u9760\u6027<\/li>\n<li>\u53ef\u9760\u6027&#xff1a;\u901a\u8fc7\u5e8f\u5217\u53f7\u3001\u786e\u8ba4\u53f7\u3001\u91cd\u4f20\u673a\u5236\u3001\u6d41\u91cf\u63a7\u5236\u548c\u62e5\u585e\u63a7\u5236\u7b49\u624b\u6bb5&#xff0c;\u4fdd\u8bc1\u6570\u636e\u80fd\u591f\u51c6\u786e\u65e0\u8bef\u5730\u5230\u8fbe\u76ee\u7684\u5730&#xff0c;\u5e76\u4e14\u4fdd\u8bc1\u6570\u636e\u7684\u987a\u5e8f\u6027<\/li>\n<li>\u5b57\u8282\u6d41&#xff1a;\u5c06\u6570\u636e\u89c6\u4e3a\u8fde\u7eed\u7684\u5b57\u8282\u6d41\u8fdb\u884c\u4f20\u8f93&#xff0c;\u6ca1\u6709\u660e\u786e\u7684\u6d88\u606f\u8fb9\u754c&#xff0c;\u5e94\u7528\u5c42\u6570\u636e\u53ef\u4ee5\u5728\u4efb\u610f\u65f6\u523b\u4ee5\u4efb\u610f\u5927\u5c0f\u53d1\u9001<\/li>\n<li>\u4f20\u8f93\u6548\u7387\u76f8\u5bf9\u8f83\u4f4e&#xff1a;\u7531\u4e8e\u9700\u8981\u8fdb\u884c\u8fde\u63a5\u5efa\u7acb\u3001\u786e\u8ba4\u3001\u91cd\u4f20\u7b49\u64cd\u4f5c&#xff0c;TCP \u7684\u4f20\u8f93\u6548\u7387\u76f8\u5bf9 UDP \u8f83\u4f4e&#xff0c;\u4f46\u5728\u5bf9\u6570\u636e\u51c6\u786e\u6027\u8981\u6c42\u9ad8\u7684\u573a\u666f\u4e0b\u662f\u5fc5\u8981\u7684<\/li>\n<\/ul>\n<\/li>\n<li>UDP\n<ul>\n<li>\u65e0\u8fde\u63a5&#xff1a;\u53d1\u9001\u6570\u636e\u524d\u4e0d\u9700\u8981\u5efa\u7acb\u8fde\u63a5&#xff0c;\u76f4\u63a5\u5c06\u6570\u636e\u62a5\u53d1\u9001\u51fa\u53bb&#xff0c;\u51cf\u5c11\u4e86\u8fde\u63a5\u5efa\u7acb\u548c\u62c6\u9664\u7684\u5f00\u9500&#xff0c;\u4f20\u8f93\u901f\u5ea6\u5feb<\/li>\n<li>\u4e0d\u53ef\u9760&#xff1a;\u4e0d\u4fdd\u8bc1\u6570\u636e\u4e00\u5b9a\u80fd\u5230\u8fbe\u76ee\u6807\u4e3b\u673a&#xff0c;\u4e5f\u4e0d\u4fdd\u8bc1\u6570\u636e\u7684\u987a\u5e8f\u548c\u5b8c\u6574\u6027&#xff0c;\u53ef\u80fd\u4f1a\u51fa\u73b0\u6570\u636e\u4e22\u5931\u3001\u91cd\u590d\u6216\u4e71\u5e8f\u7684\u60c5\u51b5<\/li>\n<li>\u6709\u6d88\u606f\u8fb9\u754c&#xff1a;\u6bcf\u4e2a UDP \u6570\u636e\u62a5\u90fd\u6709\u660e\u786e\u7684\u8fb9\u754c&#xff0c;\u5e94\u7528\u5c42\u4e00\u6b21\u53d1\u9001\u7684\u6570\u636e\u4f1a\u4f5c\u4e3a\u4e00\u4e2a\u5b8c\u6574\u7684\u6d88\u606f\u8fdb\u884c\u4f20\u8f93&#xff0c;\u63a5\u6536\u65b9\u4e5f\u4f1a\u6309\u7167\u6d88\u606f\u8fb9\u754c\u8fdb\u884c\u63a5\u6536<\/li>\n<li>\u4f20\u8f93\u6548\u7387\u9ad8&#xff1a;\u6ca1\u6709\u590d\u6742\u7684\u786e\u8ba4\u548c\u91cd\u4f20\u673a\u5236&#xff0c;UDP \u7684\u4f20\u8f93\u6548\u7387\u8f83\u9ad8&#xff0c;\u9002\u5408\u5bf9\u5b9e\u65f6\u6027\u8981\u6c42\u9ad8\u3001\u5141\u8bb8\u4e00\u5b9a\u6570\u636e\u4e22\u5931\u7684\u573a\u666f<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h2>\u56db\u3001\u7f51\u7edc\u5b57\u8282\u5e8f<\/h2>\n<p>\u5728C\u8bed\u8a00\u7684\u5b66\u4e60\u8fc7\u7a0b\u4e2d&#xff0c;\u6211\u4eec\u8ba4\u8bc6\u5230\u5185\u5b58&#xff08;\u5305\u62ec\u78c1\u76d8\u6587\u4ef6&#xff09;\u5f53\u4e2d\u7684\u591a\u5b57\u8282\u6570\u636e\u76f8\u5bf9\u4e8e\u5185\u5b58\u5730\u5740\u6709\u5927\u5c0f\u7aef\u4e4b\u5206&#xff0c;\u5b9e\u9645\u4e0a&#xff0c;\u7f51\u7edc\u4e0a\u4e5f\u6709\u5927\u5c0f\u7aef\u4e4b\u5206&#xff0c;\u5927\u7aef\u5c31\u662f\u6570\u636e\u7684\u9ad8\u4f4d\u5b57\u8282\u5b58\u4e8e\u4f4e\u5730\u5740&#xff0c;\u4f4e\u4f4d\u5b57\u8282\u5b58\u4e8e\u9ad8\u5730\u5740&#xff0c;\u5c0f\u7aef\u5c31\u662f\u6570\u636e\u7684\u4f4e\u4f4d\u5b57\u8282\u5b58\u4e8e\u4f4e\u5730\u5740&#xff0c;\u9ad8\u4f4d\u5b57\u8282\u5b58\u4e8e\u9ad8\u5730\u5740 \u5bf9\u4e8e\u5927\u7aef&#xff08;\u5c0f\u7aef&#xff09;\u6765\u8bf4&#xff0c;\u5bf9\u4e8e 32 \u4f4d\u6574\u65700x12345678&#xff0c;\u9ad8\u4f4d\u5b57\u82820x12\u5b58\u4e8e\u5185\u5b58\u7684\u4f4e&#xff08;\u9ad8&#xff09;\u5730\u5740&#xff0c;\u63a5\u7740\u4f9d\u6b21\u662f0x34\u30010x56\u30010x78\u5b58\u4e8e\u66f4\u9ad8&#xff08;\u4f4e&#xff09;\u5730\u5740<\/p>\n<p>\u7f51\u7edc\u5b57\u8282\u5e8f\u89c4\u5b9a\u4e86\u5728\u7f51\u7edc\u4e0a\u4f20\u8f93\u6570\u636e\u65f6&#xff0c;\u7edf\u4e00\u91c7\u7528\u5927\u7aef\u5e8f&#xff0c;\u5982\u679c\u4e3b\u673a\u662f\u5c0f\u7aef\u5b58\u50a8&#xff0c;\u5728\u6536\u5230\u6570\u636e\u540e&#xff0c;\u53ef\u4ee5\u901a\u8fc7\u4e00\u4e9b\u51fd\u6570\u5c06\u5927\u7aef\u6570\u636e\u8f6c\u5316\u6210\u5c0f\u7aef&#xff0c;\u4e0b\u9762\u662fC\u8bed\u8a00\u7684\u51fd\u6570<\/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;arpa\/inet.h&gt;<\/span><\/span><br \/>\n<span class=\"token class-name\">uint32_t<\/span> <span class=\"token function\">htonl<\/span><span class=\"token punctuation\">(<\/span><span class=\"token class-name\">uint32_t<\/span> hostlong<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><span class=\"token comment\">\/\/\u5c06\u4e00\u4e2a32\u4f4d\u65e0\u7b26\u53f7\u6574\u6570\u4ece\u4e3b\u673a\u5b57\u8282\u5e8f\u8f6c\u6362\u4e3a\u7f51\u7edc\u5b57\u8282\u5e8f<\/span><br \/>\n<span class=\"token class-name\">uint16_t<\/span> <span class=\"token function\">htons<\/span><span class=\"token punctuation\">(<\/span><span class=\"token class-name\">uint16_t<\/span> hostshort<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><span class=\"token comment\">\/\/\u5c06\u4e00\u4e2a 16 \u4f4d\u7684\u65e0\u7b26\u53f7\u6574\u6570\u4ece\u4e3b\u673a\u5b57\u8282\u5e8f\u8f6c\u6362\u4e3a\u7f51\u7edc\u5b57\u8282\u5e8f<\/span><br \/>\n<span class=\"token class-name\">uint32_t<\/span> <span class=\"token function\">ntohl<\/span><span class=\"token punctuation\">(<\/span><span class=\"token class-name\">uint32_t<\/span> netlong<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><span class=\"token comment\">\/\/\u5c06\u4e00\u4e2a 32 \u4f4d\u7684\u65e0\u7b26\u53f7\u6574\u6570\u4ece\u7f51\u7edc\u5b57\u8282\u5e8f\u8f6c\u6362\u4e3a\u4e3b\u673a\u5b57\u8282\u5e8f<\/span><br \/>\n<span class=\"token class-name\">uint16_t<\/span> <span class=\"token function\">ntohs<\/span><span class=\"token punctuation\">(<\/span><span class=\"token class-name\">uint16_t<\/span> netshort<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><span class=\"token comment\">\/\/\u5c06\u4e00\u4e2a 16 \u4f4d\u7684\u65e0\u7b26\u53f7\u6574\u6570\u4ece\u7f51\u7edc\u5b57\u8282\u5e8f\u8f6c\u6362\u4e3a\u4e3b\u673a\u5b57\u8282\u5e8f<\/span><\/p>\n<h2>\u4e94\u3001\u7f51\u7edc\u901a\u4fe1\u7684\u672c\u8d28<\/h2>\n<p>\u5f53\u6211\u4eec\u8fdb\u884c\u7f51\u7edc\u4e4b\u95f4\u901a\u4fe1\u7684\u65f6\u5019&#xff0c;\u6bd4\u5982\u6211\u4eec\u5728\u5fae\u4fe1\u4e0a\u53d1\u9001\u4e00\u4e2ahello world&#xff0c;\u9996\u5148\u6211\u4eec\u8981\u6253\u5f00\u5fae\u4fe1&#xff0c;\u7136\u540e\u8f93\u5165\u53d1\u51fa&#xff0c;\u7136\u540e\u53e6\u4e00\u4e2a\u7528\u6237\u5728\u5fae\u4fe1\u4e0a\u6536\u5230hello world&#xff0c;\u8fd9\u4e2a\u8fc7\u7a0b\u5b9e\u9645\u4e0a&#xff0c;\u5c06\u4e2d\u95f4\u5f88\u591a\u8fc7\u7a0b\u90fd\u5ffd\u7565\u6389&#xff0c;\u5c31\u662f\u4e24\u4e2a\u8fdb\u7a0b\u5728\u8fdb\u884c\u8fdb\u7a0b\u95f4\u901a\u4fe1&#xff0c;\u5f53\u6211\u4eec\u4ee5\u8fd9\u4e2a\u89c6\u89d2\u770b\u5f85\u7f51\u7edc\u901a\u4fe1\u7684\u65f6\u5019&#xff0c;\u90a3\u4e48\u7f51\u7edc\u901a\u4fe1\u7684\u8fc7\u7a0b\u4e5f\u5c31\u6210\u4e86\u4e00\u79cd\u4ecb\u8d28&#xff0c;\u7c7b\u4f3c\u4e8e\u7ba1\u9053\u6216\u8005\u5171\u4eab\u5185\u5b58\u4e00\u6837\u7684\u901a\u4fe1\u4fe1\u9053<\/p>\n<h2>\u516d\u3001\u5168\u9762\u8ba4\u8bc6\u7f51\u7edc\u901a\u4fe1<\/h2>\n<p>\u5728 TCP\/IP \u56db\u5c42\u6a21\u578b\u4e2d&#xff0c;\u6bcf\u4e00\u5c42\u90fd\u5305\u542b\u4e86\u591a\u79cd\u4e0d\u540c\u7684\u534f\u8bae&#xff0c;\u8fd9\u4e9b\u534f\u8bae\u5404\u81ea\u627f\u62c5\u7740\u4e0d\u540c\u7684\u529f\u80fd&#xff0c;\u5171\u540c\u534f\u4f5c\u4ee5\u5b9e\u73b0\u7f51\u7edc\u901a\u4fe1&#xff0c;\u4e0b\u9762\u8fd9\u4e9b\u5185\u5bb9\u9700\u8981\u7684\u770b\u4e00\u4e0b&#xff0c;\u8fd9\u91cc\u4e3b\u8981\u662f\u6307\u51fa\u6bcf\u5c42\u90fd\u6709\u591a\u79cd\u534f\u8bae&#xff0c;\u6240\u4ee5\u5728\u6570\u636e\u89e3\u6790\u7684\u8fc7\u7a0b\u4e2d&#xff0c;\u90fd\u662f\u901a\u8fc7\u62a5\u5934\u91cc\u9762\u7684\u6e90xx\u53f7\u548c\u76ee\u6807xx\u53f7\u8d77\u5230\u7684\u4f5c\u7528&#xff0c;\u7cbe\u786e\u627e\u5230\u8981\u627e\u5230\u54ea\u4e2a\u534f\u8bae\u89e3\u6790<\/p>\n<ul>\n<li>\n<p>\u7f51\u7edc\u63a5\u53e3\u5c42 \u7f51\u7edc\u63a5\u53e3\u5c42\u8d1f\u8d23\u5c06\u6570\u636e\u5e27\u4ece\u4e00\u4e2a\u8282\u70b9\u4f20\u8f93\u5230\u53e6\u4e00\u4e2a\u8282\u70b9&#xff0c;\u5904\u7406\u4e0e\u7269\u7406\u7f51\u7edc\u7684\u8fde\u63a5\u548c\u6570\u636e\u4f20\u8f93&#xff0c;\u8be5\u5c42\u5e38\u89c1\u7684\u534f\u8bae\u6709&#xff1a;<\/p>\n<ul>\n<li>\u4ee5\u592a\u7f51\u534f\u8bae&#xff08;Ethernet&#xff09;&#xff1a;\u662f\u76ee\u524d\u5e94\u7528\u6700\u5e7f\u6cdb\u7684\u5c40\u57df\u7f51\u6280\u672f&#xff0c;\u5b9a\u4e49\u4e86\u5c40\u57df\u7f51\u4e2d\u6570\u636e\u5e27\u7684\u683c\u5f0f\u548c\u4f20\u8f93\u89c4\u5219&#xff0c;\u4ee5\u592a\u7f51\u5e27\u5305\u542b\u6e90 MAC \u5730\u5740\u3001\u76ee\u7684 MAC \u5730\u5740\u3001\u7c7b\u578b\u5b57\u6bb5\u548c\u6570\u636e\u7b49\u90e8\u5206&#xff0c;\u7528\u4e8e\u5728\u5c40\u57df\u7f51\u5185\u8fdb\u884c\u6570\u636e\u7684\u4f20\u8f93\u548c\u4ea4\u6362<\/li>\n<li>Wi &#8211; Fi \u534f\u8bae&#xff08;IEEE 802.11&#xff09;&#xff1a;\u7528\u4e8e\u65e0\u7ebf\u5c40\u57df\u7f51\u901a\u4fe1&#xff0c;\u6709\u591a\u4e2a\u4e0d\u540c\u7684\u6807\u51c6\u7248\u672c&#xff08;\u5982 802.11a\u3001802.11b\u3001802.11g\u3001802.11n\u3001802.11ac\u3001802.11ax \u7b49&#xff09;&#xff0c;\u6bcf\u4e2a\u7248\u672c\u5728\u4f20\u8f93\u901f\u7387\u3001\u9891\u6bb5\u3001\u8986\u76d6\u8303\u56f4\u7b49\u65b9\u9762\u6709\u6240\u4e0d\u540c<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u7f51\u7edc\u5c42 \u7f51\u7edc\u5c42\u4e3b\u8981\u8d1f\u8d23\u5c06\u6570\u636e\u5305\u4ece\u6e90\u4e3b\u673a\u4f20\u8f93\u5230\u76ee\u6807\u4e3b\u673a&#xff0c;\u8fdb\u884c\u8def\u7531\u9009\u62e9\u548c\u5bfb\u5740&#xff0c;\u8be5\u5c42\u7684\u5e38\u89c1\u534f\u8bae\u6709&#xff1a;<\/p>\n<ul>\n<li>\u7f51\u9645\u534f\u8bae&#xff08;IP&#xff09;&#xff1a;\u662f TCP\/IP \u534f\u8bae\u65cf\u7684\u6838\u5fc3\u534f\u8bae\u4e4b\u4e00&#xff0c;\u5206\u4e3a IPv4 \u548c IPv6 \u4e24\u4e2a\u7248\u672c&#xff0c;IPv4 \u4f7f\u7528 32 \u4f4d\u5730\u5740&#xff0c;\u76ee\u524d\u5730\u5740\u8d44\u6e90\u65e5\u76ca\u7d27\u5f20&#xff1b;IPv6 \u4f7f\u7528 128 \u4f4d\u5730\u5740&#xff0c;\u80fd\u591f\u63d0\u4f9b\u5927\u91cf\u7684\u5730\u5740\u7a7a\u95f4&#xff0c;IP \u534f\u8bae\u8d1f\u8d23\u5c06\u6570\u636e\u5305\u4ece\u6e90\u4e3b\u673a\u901a\u8fc7\u7f51\u7edc\u8def\u7531\u5230\u76ee\u6807\u4e3b\u673a&#xff0c;\u5b83\u53ea\u63d0\u4f9b\u5c3d\u529b\u800c\u4e3a\u7684\u670d\u52a1&#xff0c;\u4e0d\u4fdd\u8bc1\u6570\u636e\u5305\u7684\u53ef\u9760\u4f20\u8f93<\/li>\n<li>\u4e92\u8054\u7f51\u63a7\u5236\u62a5\u6587\u534f\u8bae&#xff08;ICMP&#xff09;&#xff1a;\u7528\u4e8e\u5728 IP \u4e3b\u673a\u3001\u8def\u7531\u5668\u4e4b\u95f4\u4f20\u9012\u63a7\u5236\u6d88\u606f&#xff0c;\u5982\u7f51\u7edc\u8fde\u901a\u6027\u6d4b\u8bd5&#xff08;ping \u547d\u4ee4\u5c31\u57fa\u4e8e ICMP \u534f\u8bae&#xff09;\u3001\u8def\u7531\u9519\u8bef\u62a5\u544a\u7b49&#xff0c;ICMP \u62a5\u6587\u5c01\u88c5\u5728 IP \u6570\u636e\u5305\u4e2d\u4f20\u8f93<\/li>\n<li>\u5730\u5740\u89e3\u6790\u534f\u8bae&#xff08;ARP&#xff09;&#xff1a;\u7528\u4e8e\u5c06 IP \u5730\u5740\u89e3\u6790\u4e3a\u5bf9\u5e94\u7684 MAC \u5730\u5740&#xff0c;\u5728\u5c40\u57df\u7f51\u4e2d&#xff0c;\u5f53\u4e00\u53f0\u4e3b\u673a\u8981\u5411\u53e6\u4e00\u53f0\u4e3b\u673a\u53d1\u9001\u6570\u636e\u65f6&#xff0c;\u9700\u8981\u77e5\u9053\u76ee\u6807\u4e3b\u673a\u7684 MAC \u5730\u5740&#xff0c;ARP \u534f\u8bae\u901a\u8fc7\u5e7f\u64ad ARP \u8bf7\u6c42\u6765\u83b7\u53d6\u76ee\u6807\u4e3b\u673a\u7684 MAC \u5730\u5740<\/li>\n<li>\u9006\u5730\u5740\u89e3\u6790\u534f\u8bae&#xff08;RARP&#xff09;&#xff1a;\u4e0e ARP \u76f8\u53cd&#xff0c;RARP \u7528\u4e8e\u5c06 MAC \u5730\u5740\u89e3\u6790\u4e3a IP \u5730\u5740&#xff0c;\u5e38\u7528\u4e8e\u65e0\u76d8\u5de5\u4f5c\u7ad9\u7b49\u8bbe\u5907&#xff0c;\u8fd9\u4e9b\u8bbe\u5907\u77e5\u9053\u81ea\u5df1\u7684 MAC \u5730\u5740&#xff0c;\u4f46\u9700\u8981\u901a\u8fc7 RARP \u534f\u8bae\u83b7\u53d6 IP \u5730\u5740<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u4f20\u8f93\u5c42 \u4f20\u8f93\u5c42\u8d1f\u8d23\u63d0\u4f9b\u7aef\u5230\u7aef\u7684\u53ef\u9760\u901a\u4fe1\u6216\u9ad8\u6548\u7684\u6570\u636e\u4f20\u8f93\u670d\u52a1&#xff0c;\u5e38\u89c1\u7684\u534f\u8bae\u6709&#xff1a;<\/p>\n<ul>\n<li>\u4f20\u8f93\u63a7\u5236\u534f\u8bae&#xff08;TCP&#xff09;&#xff1a;\u662f\u4e00\u79cd\u9762\u5411\u8fde\u63a5\u7684\u3001\u53ef\u9760\u7684\u4f20\u8f93\u534f\u8bae&#xff0c;TCP \u901a\u8fc7\u4e09\u6b21\u63e1\u624b\u5efa\u7acb\u8fde\u63a5&#xff0c;\u5728\u6570\u636e\u4f20\u8f93\u8fc7\u7a0b\u4e2d\u63d0\u4f9b\u786e\u8ba4\u3001\u91cd\u4f20\u3001\u6d41\u91cf\u63a7\u5236\u548c\u62e5\u585e\u63a7\u5236\u7b49\u673a\u5236&#xff0c;\u4fdd\u8bc1\u6570\u636e\u7684\u53ef\u9760\u4f20\u8f93\u548c\u987a\u5e8f\u6027&#xff0c;\u5e38\u7528\u4e8e\u5bf9\u6570\u636e\u51c6\u786e\u6027\u8981\u6c42\u8f83\u9ad8\u7684\u5e94\u7528&#xff0c;\u5982\u6587\u4ef6\u4f20\u8f93\u3001\u7535\u5b50\u90ae\u4ef6\u3001\u7f51\u9875\u6d4f\u89c8\u7b49<\/li>\n<li>\u7528\u6237\u6570\u636e\u62a5\u534f\u8bae&#xff08;UDP&#xff09;&#xff1a;\u662f\u4e00\u79cd\u65e0\u8fde\u63a5\u7684\u3001\u4e0d\u53ef\u9760\u7684\u4f20\u8f93\u534f\u8bae\u3002UDP \u4e0d\u4fdd\u8bc1\u6570\u636e\u7684\u53ef\u9760\u4f20\u8f93\u548c\u987a\u5e8f\u6027&#xff0c;\u4f46\u5177\u6709\u4f20\u8f93\u6548\u7387\u9ad8\u3001\u5f00\u9500\u5c0f\u7684\u7279\u70b9&#xff0c;\u5e38\u7528\u4e8e\u5bf9\u5b9e\u65f6\u6027\u8981\u6c42\u8f83\u9ad8\u3001\u5141\u8bb8\u4e00\u5b9a\u6570\u636e\u4e22\u5931\u7684\u5e94\u7528&#xff0c;\u5982\u5b9e\u65f6\u89c6\u9891\u548c\u97f3\u9891\u6d41\u3001\u6e38\u620f\u7b49<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u5e94\u7528\u5c42<\/p>\n<ul>\n<li>\u8d85\u6587\u672c\u4f20\u8f93\u534f\u8bae&#xff08;HTTP&#xff09;&#xff1a;\u7528\u4e8e\u5728 Web \u6d4f\u89c8\u5668\u548c Web \u670d\u52a1\u5668\u4e4b\u95f4\u4f20\u8f93\u8d85\u6587\u672c&#xff08;\u5982 HTML \u9875\u9762&#xff09;&#xff0c;\u662f\u4e92\u8054\u7f51\u4e0a\u5e94\u7528\u6700\u4e3a\u5e7f\u6cdb\u7684\u4e00\u79cd\u534f\u8bae\u3002HTTP \u662f\u65e0\u72b6\u6001\u7684\u534f\u8bae&#xff0c;\u6bcf\u6b21\u8bf7\u6c42\u90fd\u662f\u72ec\u7acb\u7684<\/li>\n<li>\u5b89\u5168\u8d85\u6587\u672c\u4f20\u8f93\u534f\u8bae&#xff08;HTTPS&#xff09;&#xff1a;\u662f HTTP \u534f\u8bae\u7684\u5b89\u5168\u7248\u672c&#xff0c;\u5b83\u5728 HTTP \u7684\u57fa\u7840\u4e0a\u52a0\u5165\u4e86 SSL\/TLS \u534f\u8bae\u8fdb\u884c\u52a0\u5bc6\u548c\u8eab\u4efd\u9a8c\u8bc1&#xff0c;\u4fdd\u8bc1\u6570\u636e\u5728\u4f20\u8f93\u8fc7\u7a0b\u4e2d\u7684\u5b89\u5168\u6027\u548c\u5b8c\u6574\u6027&#xff0c;\u5e38\u7528\u4e8e\u5728\u7ebf\u652f\u4ed8\u3001\u767b\u5f55\u7b49\u5b89\u5168\u8981\u6c42\u8f83\u9ad8\u7684\u573a\u666f<\/li>\n<li>\u6587\u4ef6\u4f20\u8f93\u534f\u8bae&#xff08;FTP&#xff09;&#xff1a;\u7528\u4e8e\u5728\u4e0d\u540c\u4e3b\u673a\u4e4b\u95f4\u8fdb\u884c\u6587\u4ef6\u7684\u4e0a\u4f20\u548c\u4e0b\u8f7d&#xff0c;\u63d0\u4f9b\u4e86\u53ef\u9760\u7684\u6587\u4ef6\u4f20\u8f93\u670d\u52a1\u3002FTP \u4f7f\u7528\u4e24\u4e2a TCP \u8fde\u63a5&#xff0c;\u4e00\u4e2a\u7528\u4e8e\u63a7\u5236\u547d\u4ee4\u7684\u4f20\u8f93&#xff0c;\u53e6\u4e00\u4e2a\u7528\u4e8e\u6570\u636e\u7684\u4f20\u8f93<\/li>\n<li>\u7b80\u5355\u90ae\u4ef6\u4f20\u8f93\u534f\u8bae&#xff08;SMTP&#xff09;&#xff1a;\u7528\u4e8e\u53d1\u9001\u7535\u5b50\u90ae\u4ef6&#xff0c;\u5b83\u89c4\u5b9a\u4e86\u90ae\u4ef6\u5ba2\u6237\u7aef\u5982\u4f55\u5c06\u90ae\u4ef6\u53d1\u9001\u5230\u90ae\u4ef6\u670d\u52a1\u5668&#xff0c;\u4ee5\u53ca\u90ae\u4ef6\u670d\u52a1\u5668\u4e4b\u95f4\u5982\u4f55\u8fdb\u884c\u90ae\u4ef6\u7684\u8f6c\u53d1<\/li>\n<li>\u90ae\u5c40\u534f\u8bae&#xff08;POP3&#xff09;&#xff1a;\u7528\u4e8e\u63a5\u6536\u7535\u5b50\u90ae\u4ef6&#xff0c;\u5141\u8bb8\u7528\u6237\u4ece\u90ae\u4ef6\u670d\u52a1\u5668\u4e0a\u4e0b\u8f7d\u90ae\u4ef6\u5230\u672c\u5730\u5ba2\u6237\u7aef\u3002<\/li>\n<li>\u4e92\u8054\u7f51\u6d88\u606f\u8bbf\u95ee\u534f\u8bae&#xff08;IMAP&#xff09;&#xff1a;\u4e5f\u662f\u7528\u4e8e\u63a5\u6536\u7535\u5b50\u90ae\u4ef6\u7684\u534f\u8bae&#xff0c;\u4e0e POP3 \u4e0d\u540c\u7684\u662f&#xff0c;IMAP \u5141\u8bb8\u7528\u6237\u5728\u90ae\u4ef6\u670d\u52a1\u5668\u4e0a\u7ba1\u7406\u90ae\u4ef6&#xff0c;\u800c\u4e0d\u4ec5\u4ec5\u662f\u4e0b\u8f7d\u90ae\u4ef6\u5230\u672c\u5730<\/li>\n<li>\u57df\u540d\u7cfb\u7edf&#xff08;DNS&#xff09;&#xff1a;\u7528\u4e8e\u5c06\u57df\u540d\u89e3\u6790\u4e3a\u5bf9\u5e94\u7684 IP \u5730\u5740&#xff0c;\u5f53\u7528\u6237\u5728\u6d4f\u89c8\u5668\u4e2d\u8f93\u5165\u57df\u540d\u65f6&#xff0c;DNS \u670d\u52a1\u5668\u4f1a\u5c06\u57df\u540d\u8f6c\u6362\u4e3a\u5bf9\u5e94\u7684 IP \u5730\u5740&#xff0c;\u4ee5\u4fbf\u6d4f\u89c8\u5668\u80fd\u591f\u627e\u5230\u5bf9\u5e94\u7684 Web \u670d\u52a1\u5668<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h2>\u4e03\u3001socket\u7f16\u7a0b\u57fa\u7840<\/h2>\n<h3>1\u3001\u8c03\u7528\u63a5\u53e3<\/h3>\n<h4>&#xff08;\u4e00&#xff09;\u521b\u5efa\u63cf\u8ff0\u7b26<\/h4>\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;sys\/socket.h&gt;<\/span><\/span><br \/>\n<span class=\"token keyword\">int<\/span> <span class=\"token function\">socket<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">int<\/span> domain<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">int<\/span> type<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">int<\/span> protocol<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>\u8fd4\u56de\u503c&#xff1a;\u6210\u529f\u8fd4\u56de\u5957\u63a5\u5b57\u63cf\u8ff0\u7b26sockfd&#xff0c;\u5931\u8d25\u8fd4\u56de-1 domain&#xff1a;\u6307\u5b9a\u901a\u4fe1\u57df<\/p>\n<table>\n<tr>\u901a\u4fe1\u57df\u610f\u4e49<\/tr>\n<tbody>\n<tr>\n<td>AF_INET<\/td>\n<td>IPv4\u7f51\u7edc\u534f\u8bae<\/td>\n<\/tr>\n<tr>\n<td>AF_INET6<\/td>\n<td>IPv6\u7f51\u7edc\u534f\u8bae<\/td>\n<\/tr>\n<tr>\n<td>AF_UNIX \u6216 AF_LOCAL<\/td>\n<td>\u7528\u4e8e\u672c\u5730\u901a\u4fe1&#xff0c;\u53ef\u5728\u540c\u4e00\u53f0\u673a\u5668\u7684\u4e0d\u540c\u8fdb\u7a0b\u95f4\u8fdb\u884c\u9ad8\u6548\u6570\u636e\u4f20\u8f93<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>type&#xff1a;\u6307\u5b9a\u5957\u63a5\u5b57\u7c7b\u578b<\/p>\n<table>\n<tr>\u5957\u63a5\u5b57\u7c7b\u578b\u610f\u4e49<\/tr>\n<tbody>\n<tr>\n<td>SOCK_STREAM<\/td>\n<td>\u6d41\u5f0f\u5957\u63a5\u5b57&#xff0c;\u57fa\u4e8eTCP\u5b9e\u73b0<\/td>\n<\/tr>\n<tr>\n<td>SOCK_DGRAM<\/td>\n<td>\u6570\u636e\u62a5\u5957\u63a5\u5b57&#xff0c;\u57fa\u4e8eUDP\u5b9e\u73b0<\/td>\n<\/tr>\n<tr>\n<td>SOCK_RAW<\/td>\n<td>\u539f\u59cb\u5957\u63a5\u5b57&#xff0c;\u5141\u8bb8\u7a0b\u5e8f\u76f4\u63a5\u8bbf\u95ee\u5e95\u5c42\u7f51\u7edc\u534f\u8bae<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>protocol&#xff1a;\u6307\u5b9a\u4e86\u4f7f\u7528\u7684\u5177\u4f53\u534f\u8bae&#xff0c;\u901a\u5e38\u5c06\u5176\u8bbe\u4e3a 0&#xff0c;\u8fd9\u6837\u7cfb\u7edf\u4f1a\u6839\u636e domain \u548c type \u81ea\u52a8\u9009\u62e9\u5408\u9002\u7684\u534f\u8bae<\/p>\n<h4>&#xff08;\u4e8c&#xff09;\u7ed1\u5b9a\u7aef\u53e3\u53f7<\/h4>\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;sys\/socket.h&gt;<\/span><\/span><br \/>\n<span class=\"token keyword\">int<\/span> <span class=\"token function\">bind<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">int<\/span> sockfd<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">const<\/span> <span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">sockaddr<\/span> <span class=\"token operator\">*<\/span>addr<span class=\"token punctuation\">,<\/span> <span class=\"token class-name\">socklen_t<\/span> addrlen<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>\u8fd4\u56de\u503c&#xff1a;\u6210\u529f\u8fd4\u56de0&#xff0c;\u5931\u8d25\u8fd4\u56de-1 sockfd&#xff1a;\u8981\u8fdb\u884c\u7ed1\u5b9a\u7684\u5957\u63a5\u5b57\u63cf\u8ff0\u7b26 addr&#xff1a;\u4e00\u4e2a\u6307\u5411 struct sockaddr \u7c7b\u578b\u7684\u6307\u9488&#xff0c;\u5b83\u5b58\u50a8\u4e86\u8981\u7ed1\u5b9a\u7684\u5730\u5740\u4fe1\u606f&#xff0c;\u5177\u4f53\u7684\u7ed3\u6784\u5728\u4e0b\u4e2a\u8bdd\u9898\u4e2d\u8bf4 addrlen&#xff1a;\u8fd9\u662f addr \u6240\u6307\u5411\u7ed3\u6784\u4f53\u7684\u957f\u5ea6&#xff0c;\u901a\u5e38\u4f7f\u7528 sizeof \u8fd0\u7b97\u7b26\u6765\u83b7\u53d6&#xff0c;\u8fd9\u91cc\u4f4d\u8f93\u5165\u578b\u53c2\u6570<\/p>\n<h4>&#xff08;\u4e09&#xff09;\u76d1\u542c\u5957\u63a5\u5b57<\/h4>\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;sys\/socket.h&gt;<\/span><\/span><br \/>\n<span class=\"token keyword\">int<\/span> <span class=\"token function\">listen<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">int<\/span> sockfd<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">int<\/span> backlog<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>\u8fd4\u56de\u503c&#xff1a;\u6210\u529f\u8fd4\u56de0&#xff0c;\u5931\u8d25\u8fd4\u56de-1 sockfd&#xff1a;\u8981\u76d1\u542c\u7684\u5957\u63a5\u5b57\u63cf\u8ff0\u7b26 backlog&#xff1a;\u6307\u5b9a\u8bf7\u6c42\u8fde\u63a5\u961f\u5217\u7684\u6700\u5927\u957f\u5ea6&#xff0c;\u5f53\u6709\u591a\u4e2a\u5ba2\u6237\u7aef\u540c\u65f6\u53d1\u8d77\u8fde\u63a5\u8bf7\u6c42\u65f6&#xff0c;\u670d\u52a1\u5668\u65e0\u6cd5\u7acb\u5373\u5904\u7406\u6240\u6709\u8bf7\u6c42&#xff0c;\u8fd9\u4e9b\u672a\u5904\u7406\u7684\u8fde\u63a5\u8bf7\u6c42\u4f1a\u88ab\u653e\u5165\u4e00\u4e2a\u961f\u5217\u4e2d\u7b49\u5f85\u5904\u7406&#xff0c;backlog \u5c31\u662f\u8fd9\u4e2a\u961f\u5217\u7684\u6700\u5927\u957f\u5ea6&#xff0c;\u5982\u679c\u961f\u5217\u5df2\u6ee1&#xff0c;\u65b0\u7684\u8fde\u63a5\u8bf7\u6c42\u5c06\u88ab\u62d2\u7edd<\/p>\n<h4>&#xff08;\u56db&#xff09;\u63a5\u6536\u8bf7\u6c42<\/h4>\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;sys\/socket.h&gt;<\/span><\/span><br \/>\n<span class=\"token keyword\">int<\/span> <span class=\"token function\">accept<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">int<\/span> sockfd<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">sockaddr<\/span> <span class=\"token operator\">*<\/span>addr<span class=\"token punctuation\">,<\/span> <span class=\"token class-name\">socklen_t<\/span> <span class=\"token operator\">*<\/span>addrlen<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>\u8fd4\u56de\u503c&#xff1a;\u6210\u529f\u8fd4\u56de\u4e00\u4e2a\u65b0\u7684\u5957\u63a5\u5b57\u63cf\u8ff0\u7b26&#xff0c;\u8fd9\u4e2a\u65b0\u7684\u5957\u63a5\u5b57\u4e13\u95e8\u7528\u4e8e\u4e0e\u53d1\u8d77\u8fde\u63a5\u8bf7\u6c42\u7684\u5ba2\u6237\u7aef\u8fdb\u884c\u6570\u636e\u4f20\u8f93&#xff0c;\u539f\u6765\u7684 sockfd \u4ecd\u7136\u7528\u4e8e\u7ee7\u7eed\u76d1\u542c\u5176\u4ed6\u5ba2\u6237\u7aef\u7684\u8fde\u63a5\u8bf7\u6c42 sockfd&#xff1a;\u8fd9\u662f\u7531 socket \u51fd\u6570\u521b\u5efa\u3001bind \u51fd\u6570\u7ed1\u5b9a\u5730\u5740\u548c\u7aef\u53e3&#xff0c;\u5e76\u4e14\u901a\u8fc7 listen \u51fd\u6570\u8bbe\u7f6e\u4e3a\u76d1\u542c\u72b6\u6001\u7684\u5957\u63a5\u5b57\u63cf\u8ff0\u7b26 addr&#xff1a;\u4e00\u4e2a\u6307\u5411 struct sockaddr \u7c7b\u578b\u7684\u6307\u9488&#xff0c;\u5b83\u5b58\u50a8\u4e86\u53d1\u8d77\u8fde\u63a5\u8bf7\u6c42\u7684\u5ba2\u6237\u7aef\u7684\u5730\u5740\u4fe1\u606f addrlen&#xff1a;\u8fd9\u662f\u4e00\u4e2a\u6307\u5411 socklen_t \u7c7b\u578b\u7684\u6307\u9488&#xff0c;\u7528\u4e8e\u4f20\u5165 addr \u6240\u6307\u5411\u7ed3\u6784\u4f53\u7684\u957f\u5ea6&#xff0c;\u5e76\u4e14\u5728\u51fd\u6570\u8fd4\u56de\u65f6&#xff0c;\u8be5\u6307\u9488\u6307\u5411\u7684\u503c\u4f1a\u88ab\u66f4\u65b0\u4e3a\u5b9e\u9645\u5b58\u50a8\u7684\u5ba2\u6237\u7aef\u5730\u5740\u4fe1\u606f\u7684\u957f\u5ea6&#xff0c;\u8fd9\u91cc\u662f\u8f93\u5165\u8f93\u51fa\u578b\u53c2\u6570<\/p>\n<h4>&#xff08;\u4e94&#xff09;\u5efa\u7acb\u8fde\u63a5<\/h4>\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;sys\/socket.h&gt;<\/span><\/span><br \/>\n<span class=\"token keyword\">int<\/span> <span class=\"token function\">connect<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">int<\/span> sockfd<span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">const<\/span> <span class=\"token keyword\">struct<\/span> <span class=\"token class-name\">sockaddr<\/span> <span class=\"token operator\">*<\/span>addr<span class=\"token punctuation\">,<\/span> <span class=\"token class-name\">socklen_t<\/span> addrlen<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>\u8fd4\u56de\u503c&#xff1a;\u6210\u529f\u8fd4\u56de0&#xff0c;\u5931\u8d25\u8fd4\u56de-1 sockfd&#xff1a;\u8981\u8fde\u63a5\u7684\u5957\u63a5\u5b57\u63cf\u8ff0\u7b26 addr&#xff1a;\u5b58\u50a8\u4e86\u8981\u8fde\u63a5\u7684\u670d\u52a1\u5668\u7684\u5730\u5740\u4fe1\u606f addrlen&#xff1a;\u8868\u793a addr \u6240\u6307\u5411\u7684\u5730\u5740\u7ed3\u6784\u4f53\u7684\u957f\u5ea6&#xff0c;\u901a\u5e38\u4f7f\u7528 sizeof \u8fd0\u7b97\u7b26\u6765\u83b7\u53d6&#xff0c;\u8f93\u5165\u578b\u53c2\u6570<\/p>\n<h3>2\u3001sockaddr\u7684\u7ed3\u6784<\/h3>\n<p>sockaddr\u7684\u7ed3\u6784\u5982\u4e0b\u56fe\u5de6\u4e00\u6240\u793a&#xff0c;\u5b9e\u9645\u4e0a&#xff0c;\u6211\u4eec\u5728\u51fd\u6570\u4e2d\u7528\u5230\u7684\u7ed3\u6784\u4f53\u662f\u53f3\u8fb9\u4e24\u4e2a\u800c\u4e0d\u662f\u5de6\u4e00&#xff0c;\u5728sockaddr\u63a5\u53d7\u4f20\u6765\u7684\u53c2\u6570\u65f6&#xff0c;\u5b83\u4f1a\u901a\u8fc7\u5224\u65ad\u524d\u976216\u4f4d2\u5b57\u8282\u7684\u5730\u5740\u7c7b\u578b\u662fAF_INET\u8fd8\u662fAF_UNIX&#xff0c;\u7136\u540e\u5728\u4f7f\u7528\u65f6\u901a\u8fc7\u5f3a\u5236\u8f6c\u5316\u8f6c\u6362\u6210sockaddr_in \u6216 sockaddr_un&#xff0c;\u524d\u8005\u7528\u4e8e\u7f51\u7edc\u95f4\u901a\u4fe1&#xff0c;\u540e\u8005\u7528\u4e8e\u57df\u95f4\u901a\u4fe1\u5373\u8fdb\u7a0b\u95f4\u901a\u4fe1<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250519202600-682b93d820c7c.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<hr \/>\n<p>\u4eca\u65e5\u5206\u4eab\u5c31\u5230\u8fd9\u91cc\u4e86~<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250519202600-682b93d8366cf.jpg\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.7k\u6b21\uff0c\u70b9\u8d5e79\u6b21\uff0c\u6536\u85cf48\u6b21\u3002\u7f51\u7edc\u7f16\u7a0b\u5957\u63a5\u5b57\u57fa\u7840\uff0c\u5c06\u7f51\u7edc\u57fa\u7840\u5185\u5bb9\u5168\u90e8\u8865\u5145\uff0c\u4e0b\u4e00\u6b65\u5c31\u53ef\u4ee5\u8fdb\u884c\u7a0b\u5e8f\u7684\u7f16\u5199\u4e86<\/p>\n","protected":false},"author":2,"featured_media":38237,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[58,230,371,123,305,78,44],"topic":[],"class_list":["post-38240","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-linux","tag-php","tag-371","tag-123","tag-305","tag-78","tag-44"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u3010Linux\u3011socket\u7f51\u7edc\u7f16\u7a0b\u57fa\u7840 - \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\/38240.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u3010Linux\u3011socket\u7f51\u7edc\u7f16\u7a0b\u57fa\u7840 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.7k\u6b21\uff0c\u70b9\u8d5e79\u6b21\uff0c\u6536\u85cf48\u6b21\u3002\u7f51\u7edc\u7f16\u7a0b\u5957\u63a5\u5b57\u57fa\u7840\uff0c\u5c06\u7f51\u7edc\u57fa\u7840\u5185\u5bb9\u5168\u90e8\u8865\u5145\uff0c\u4e0b\u4e00\u6b65\u5c31\u53ef\u4ee5\u8fdb\u884c\u7a0b\u5e8f\u7684\u7f16\u5199\u4e86\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/38240.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-05-19T20:26:01+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250519202559-682b93d7de18e.jpg\" \/>\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=\"4 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/38240.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/38240.html\",\"name\":\"\u3010Linux\u3011socket\u7f51\u7edc\u7f16\u7a0b\u57fa\u7840 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-05-19T20:26:01+00:00\",\"dateModified\":\"2025-05-19T20:26:01+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/38240.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/38240.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/38240.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u3010Linux\u3011socket\u7f51\u7edc\u7f16\u7a0b\u57fa\u7840\"}]},{\"@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":"\u3010Linux\u3011socket\u7f51\u7edc\u7f16\u7a0b\u57fa\u7840 - \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\/38240.html","og_locale":"zh_CN","og_type":"article","og_title":"\u3010Linux\u3011socket\u7f51\u7edc\u7f16\u7a0b\u57fa\u7840 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.7k\u6b21\uff0c\u70b9\u8d5e79\u6b21\uff0c\u6536\u85cf48\u6b21\u3002\u7f51\u7edc\u7f16\u7a0b\u5957\u63a5\u5b57\u57fa\u7840\uff0c\u5c06\u7f51\u7edc\u57fa\u7840\u5185\u5bb9\u5168\u90e8\u8865\u5145\uff0c\u4e0b\u4e00\u6b65\u5c31\u53ef\u4ee5\u8fdb\u884c\u7a0b\u5e8f\u7684\u7f16\u5199\u4e86","og_url":"https:\/\/www.wsisp.com\/helps\/38240.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-05-19T20:26:01+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250519202559-682b93d7de18e.jpg"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"4 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/38240.html","url":"https:\/\/www.wsisp.com\/helps\/38240.html","name":"\u3010Linux\u3011socket\u7f51\u7edc\u7f16\u7a0b\u57fa\u7840 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-05-19T20:26:01+00:00","dateModified":"2025-05-19T20:26:01+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/38240.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/38240.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/38240.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u3010Linux\u3011socket\u7f51\u7edc\u7f16\u7a0b\u57fa\u7840"}]},{"@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\/38240","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=38240"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/38240\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/38237"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=38240"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=38240"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=38240"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=38240"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}