{"id":14991,"date":"2025-04-18T21:37:43","date_gmt":"2025-04-18T13:37:43","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/14991.html"},"modified":"2025-04-18T21:37:43","modified_gmt":"2025-04-18T13:37:43","slug":"%e7%bd%91%e7%bb%9c%e7%bc%96%e7%a8%8b-%e5%a5%97%e6%8e%a5%e5%ad%97%e3%80%81%e5%88%9b%e5%bb%ba%e6%9c%8d%e5%8a%a1%e5%99%a8%e3%80%81%e5%88%9b%e5%bb%ba%e5%ae%a2%e6%88%b7%e7%ab%af","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/14991.html","title":{"rendered":"\u7f51\u7edc\u7f16\u7a0b\u2014\u2014\u5957\u63a5\u5b57\u3001\u521b\u5efa\u670d\u52a1\u5668\u3001\u521b\u5efa\u5ba2\u6237\u7aef"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"877\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418133740-680255a4b4118.png\" width=\"2201\" \/><\/p>\n<h2>\u4e00\u3001\u5957\u63a5\u5b57<\/h2>\n<h3 id=\"WYhw-1742299188171\">1.1\u4ec0\u4e48\u662f\u5957\u63a5\u5b57<\/h3>\n<p>\u5957\u63a5\u5b57\u6587\u4ef6&#xff0c;\u539f\u672c\u5c31\u662f\u4e00\u4e2a\u548c\u7ba1\u9053\u6587\u4ef6\u7c7b\u4f3c&#xff0c;\u7528\u6765\u5b9e\u73b0\u8fdb\u7a0b\u95f4\u901a\u4fe1\u7684\u4e00\u4e2a\u6587\u4ef6<\/p>\n<p>\u65e2\u7136\u6709\u4e86\u7ba1\u9053\u6587\u4ef6&#xff0c;\u5f53\u65f6\u4e3a\u4ec0\u4e48\u8fd8\u8981\u5f00\u53d1\u5957\u63a5\u5b57\u6587\u4ef6&#xff0c;\u53bb\u5b9e\u73b0\u8fdb\u7a0b\u7684\u901a\u4fe1<\/p>\n<p>\u56e0\u4e3a\u7ba1\u9053\u6587\u4ef6\u662f\u534a\u53cc\u5de5\u6a21\u5f0f\u7684<\/p>\n<p>\u5957\u63a5\u5b57\u6587\u4ef6\u662f\u5168\u53cc\u5de5\u6a21\u5f0f\u7684<\/p>\n<p>\u4f46\u662f\u540e\u6765&#xff0c;\u6709\u4e86OSI 7\u5c42\u6a21\u578b\u4ee5\u53caTCP\u534f\u8bae 4\u5c42\u6a21\u578b\u4e4b\u540e<\/p>\n<p>\u5957\u63a5\u5b57\u6587\u4ef6\u5c31\u8fdb\u5316\u51fa\u4e86\u65b0\u7684\u529f\u80fd&#xff1a;<\/p>\n<p>\u5957\u63a5\u5b57\u6587\u4ef6\u4e2d\u5141\u8bb8\u5b58\u653e ip \u548c port \u4ee5\u5b9e\u73b0\u6570\u636e\u7684\u8de8\u4e3b\u673a\u4f20\u8f93<\/p>\n<p>\u539f\u5148\u53ea\u80fd\u5b9e\u73b0\u8fdb\u7a0b\u95f4\u901a\u4fe1\u7684\u5957\u63a5\u5b57&#xff0c;\u5c31\u6709\u4e86\u4e00\u4e2a\u65b0\u7684\u540d\u5b57&#xff1a;\u57df\u5957\u63a5\u5b57<\/p>\n<h3 id=\"zKzk-1742299188198\">1.2 \u5982\u4f55\u521b\u5efa\u4e00\u4e2a\u5957\u63a5\u5b57\u6587\u4ef6&#xff1a;socket<\/h3>\n<p>\u51fd\u6570\u539f\u578b&#xff1a;int socket(int domain, int type, int protocol);<br \/>\n\u529f\u80fd\u63cf\u8ff0&#xff1a;\u521b\u5efa\u4e00\u4e2a\u5957\u63a5\u5b57\u6587\u4ef6&#xff0c;\u53c2\u6570\u4e0d\u540c&#xff0c;\u529f\u80fd\u7c7b\u578b\u5c31\u4f1a\u4e0d\u540c<br \/>\n\u53c2\u6570\u63cf\u8ff0&#xff1a;<br \/>\n    \u53c2\u6570 domain:\u7f51\u7edc\u4ecb\u8d28&#xff0c;\u5e38\u7528\u7684\u6709\u4ee5\u4e0b\u51e0\u79cd<br \/>\n        AF_UNIX,AF_LOCAL : \u672c\u5730\u901a\u4fe1\u534f\u8bae&#xff0c;\u5176\u5b9e\u5c31\u662f\u7ed9\u57df\u5957\u63a5\u5b57\u7528\u7684<br \/>\n        AF_INET&#xff1a;ipv4 \u5730\u5740\u534f\u8bae<br \/>\n        AF_INET6&#xff1a;ipv6 \u5730\u5740\u534f\u8bae<br \/>\n        \u6700\u5e38\u7528\u7684\u5c31\u662f&#xff1a; AF_INET<br \/>\n    \u53c2\u6570 type&#xff1a;\u5957\u63a5\u5b57\u7c7b\u578b&#xff0c;\u6709\u4ee5\u4e0b2\u4e2a\u5e38\u7528\u7c7b\u578b<br \/>\n        SOCK_STREAM&#xff1a;\u63d0\u4f9b\u4e00\u79cd\u6709\u5e8f\u7684\u3001\u53ef\u9760\u7684\u3001\u5168\u53cc\u5de5\u7684\u3001\u57fa\u4e8e\u8fde\u63a5\u7684\u5b57\u8282\u6d41\u5957\u63a5\u5b57<br \/>\n            \u8fd9\u4e2a\u63cf\u8ff0\u4e00\u770b\u5c31\u77e5\u9053&#xff0c;tcp\u534f\u8bae\u7528\u7684\u5c31\u662f\u8fd9\u79cd\u5957\u63a5\u5b57<br \/>\n        SOCK_DGRAM&#xff1a;\u63d0\u4f9b\u4e00\u79cd\u6570\u636e\u62a5\u6587\u5f62\u5f0f\u7684&#xff0c;\u975e\u8fde\u63a5\u7684&#xff0c;\u4e0d\u53ef\u9760\u7684&#xff0c;\u53d1\u9001\u7684\u6570\u636e\u6709\u6700\u5927\u957f\u5ea6\u9650\u5236\u7684\u5957\u63a5\u5b57<br \/>\n            \u8fd9\u4e2a\u63cf\u8ff0\u4e00\u770b\u5c31\u77e5\u9053&#xff0c;udp\u534f\u8bae\u4f7f\u7528\u7684\u662f\u8fd9\u79cd\u5957\u63a5\u5b57<br \/>\n    \u53c2\u6570 protocol: \u4e00\u822c\u76f4\u63a5\u51990<br \/>\n        \u8868\u793a&#xff1a;\u7f51\u7edc\u901a\u4fe1\u534f\u8bae\u4f1a\u6839\u636e\u5957\u63a5\u5b57\u7684\u7c7b\u578b\u81ea\u52a8\u9009\u53d6<br \/>\n            \u5982\u679c\u5957\u63a5\u5b57\u7c7b\u578b\u4e3a SOCK_STREAM&#xff0c;protocol \u4e3a0&#xff0c;\u5219\u81ea\u52a8\u9009\u7528tcp\u534f\u8bae<br \/>\n            \u5982\u679c\u5957\u63a5\u5b57\u7c7b\u578b\u4e3a SOCK_DGRAM&#xff0c;protocol \u4e3a0&#xff0c;\u5219\u81ea\u52a8\u9009\u7528udp\u534f\u8bae<br \/>\n\u8fd4\u56de\u503c&#xff1a;\u6210\u529f\u521b\u5efa\u5957\u63a5\u5b57&#xff0c;\u8fd4\u56de\u5957\u63a5\u5b57\u7684\u63cf\u8ff0\u7b26&#xff0c;\u5931\u8d25\u8fd4\u56de-1<br \/>\n    \u5957\u63a5\u5b57\u63cf\u8ff0\u7b26\u548c\u6587\u4ef6\u63cf\u8ff0\u4e00\u56de\u4e8b\u513f&#xff0c;\u9075\u5faa\u6700\u5c0f\u672a\u4f7f\u7528\u539f\u5219 <\/p>\n<h3 id=\"cjJ5-1742299188245\">1.3 \u5982\u4f55\u5411\u5957\u63a5\u5b57\u6587\u4ef6\u4e2d\u5199\u5165ip \u548c port<\/h3>\n<p>\u5957\u63a5\u5b57\u5199\u5165ip\u548cport\u5176\u5b9e\u5c31\u662f\u660e\u786e\u4e00\u4e0bip\u548cport\u5230\u5e95\u662f\u591a\u5c11<\/p>\n<p>\u4e4b\u524d\u8bb2\u8fc7&#xff0c;\u670d\u52a1\u5668\u548c\u5ba2\u6237\u7aef\u90fd\u9700\u8981\u660e\u786eip\u548cport<\/p>\n<p>\u4e5f\u5c31\u662f\u8bf4&#xff0c;\u670d\u52a1\u5668\u5957\u63a5\u5b57\u548c\u5ba2\u6237\u7aef\u5957\u63a5\u5b57&#xff0c;\u90fd\u9700\u8981\u5c06ip\u548cport\u5199\u5165\u5957\u63a5\u5b57\u91cc\u9762<\/p>\n<h4 id=\"jnxZ-1742299188253\">1.3.1 \u5148\u8981\u51c6\u5907\u4e00\u4e2a\u5730\u5740\u4fe1\u606f\u7ed3\u6784\u4f53&#xff1a;struct sockaddr_in<\/h4>\n<p>\u8be5\u7ed3\u6784\u4f53\u7ed3\u6784\u5982\u4e0b&#xff1a;<br \/>\nstruct sockaddr_in{<br \/>\n    unsigned short sin_family; \/\/ \u8fd9\u662f\u4e00\u4e2a\u6807\u8bb0\u4f4d&#xff0c;\u56fa\u5b9a\u5199 AF_INET<br \/>\n    unsigned short sin_port; \/\/ \u7aef\u53e3\u53f7<br \/>\n    struct in_addr sin_addr;\/\/ \u4e00\u4e2a\u7ed3\u6784\u4f53&#xff0c;\u7ed3\u6784\u5982\u4e0b<br \/>\n        struct in_addr{<br \/>\n            unsigned int s_addr; \/\/ \u7528\u6765\u5b58\u653eip\u5730\u5740\u7684\u53d8\u91cf<br \/>\n        }<br \/>\n    unsigned char zero[8]; \/\/ \u6ca1\u6709\u5b9e\u9645\u610f\u4e49&#xff0c;\u5b8c\u5168\u4e3a\u4e86\u5b57\u8282\u5bf9\u9f50\u586b\u5145\u5927\u5c0f<br \/>\n}<\/p>\n<p>\u5b9e\u4f8b&#xff1a;\u51c6\u5907\u5c06 &#034;192.168.1.1&#034; \u548c 8888 \u7aef\u53e3\u5199\u5165\u7ed3\u6784\u4f53\u4e2d&#xff0c;\u4e3a\u672a\u6765\u5199\u5165\u5957\u63a5\u5b57\u4e2d\u505a\u51c6\u5907<br \/>\n    struct sockaddr_in addr &#061; {0};<br \/>\n    addr.sin_family &#061; AF_INET;<br \/>\n    addr.sin_port &#061; htons(8888); \/\/ \u56e0\u4e3a\u672c\u5730\u5b57\u8282\u5e8f\u548c\u7f51\u7edc\u5b57\u8282\u5e8f\u4e0d\u4e00\u5b9a\u4e00\u81f4&#xff0c;\u6240\u4ee5\u7aef\u53e3\u53f7\u5728\u8fdb\u5165\u7f51\u7edc\u4e4b\u524d&#xff0c;\u4e00\u5b9a\u8981\u8f6c\u6362\u6210\u5927\u7aef\u5b57\u8282\u5e8f<br \/>\n    addr.sin_addr.s_addr &#061; inet_addr(&#034;192.168.1.1&#034;); <\/p>\n<h4 id=\"bEKe-1742299188289\">1.3.2 \u5c06\u51c6\u5907\u597d\u7684\u5b58\u6709ip\u548cport\u7684\u7ed3\u6784\u4f53\u5199\u5165\u5957\u63a5\u5b57\u4e2d<\/h4>\n<p>\u51fd\u6570\u539f\u578b&#xff1a;int bind(int sockfd, const struct sockaddr *addr,socklen_t addrlen);<br \/>\n\u529f\u80fd\u63cf\u8ff0&#xff1a;\u5c06\u5199\u6709ip\u548cport\u5730\u5740\u4fe1\u606f\u7ed3\u6784\u4f53&#xff0c;\u5199\u5165\u5957\u63a5\u4e2d<br \/>\n\u53c2\u6570\u63cf\u8ff0&#xff1a;<br \/>\n    \u53c2\u6570 sockfd&#xff1a;\u51c6\u5907\u5199\u5165ip\u548cport\u7684\u5957\u63a5\u5b57<br \/>\n    \u53c2\u6570 addr&#xff1a;\u5199\u6709ip\u548cport\u7684\u7ed3\u6784\u4f53\u5730\u5740,\u8be5\u7ed3\u6784\u4f53\u5982\u4e0b<br \/>\n        struct sockaddr {<br \/>\n            unsigned short sa_family;  \/\/ \u56fa\u5b9a\u5199 AF_INET<br \/>\n            char        sa_data[14]; \/\/ \u8fd9\u4e2a14\u4e2a\u5b57\u8282\u7684\u5185\u5b58\u91cc\u9762&#xff0c;\u5c31\u662f\u7528\u6765\u5b58\u653e ip \u548c port\u7684<br \/>\n        }<br \/>\n        \u5982\u679c\u4f7f\u7528\u8fd9\u4e2a\u7ed3\u6784\u4f53\u53bb\u5b58\u653eip\u548cport\u7684\u8bdd&#xff0c;\u4ee3\u7801\u5982\u4e0b<\/p>\n<p>    \u53c2\u6570 addrlen&#xff1a;\u5c31\u662f\u7b2c\u4e8c\u4e2a\u53c2\u6570 addr \u7684\u5b9e\u9645\u5360\u7528\u957f\u5ea6<br \/>\n\u8fd4\u56de\u503c&#xff1a;\u6210\u529f\u8fd4\u56de0&#xff0c;\u5931\u8d25\u8fd4\u56de-1\u3002bind\u51fd\u6570\u975e\u5e38\u5bb9\u6613\u62a5\u9519&#xff0c;\u53ea\u8981\u7ed1\u5b9a\u7684\u7aef\u53e3\u53f7\u5df2\u7ecf\u88ab\u7528\u4e86&#xff0c;\u5c31\u4f1a\u62a5\u9519<\/p>\n<p>\u8fd9\u4e2a struct sockaddr \u8fd9\u4e2a\u7ed3\u6784\u4f53\u6211\u4eec\u6210\u4e3a\u901a\u7528\u5730\u5740\u7ed3\u6784\u4f53<br \/>\n\u4e8b\u5b9e\u4e0a\u67092\u4e2a\u7ed3\u6784\u4f53\u4f1a\u901a\u8fc7\u6211\u4eec\u6240\u4ecb\u7ecd\u7684\u5730\u5740\u4e0a\u76840101\u76f4\u63a5\u8d4b\u503c\u7684\u5f62\u5f0f\u8f6c\u6362\u6210 struct sockaddr \u8fd9\u4e2a\u7ed3\u6784\u4f53<br \/>\nstruct sockaddr_in<br \/>\nstruct sockaddr_un<\/p>\n<p>\u8c03\u7528\u5f62\u5f0f<br \/>\n    struct sockaddr_in addr &#061; {0};<br \/>\n    addr.sin_family &#061; AF_INET;<br \/>\n    addr.sin_port &#061; htons(8888); \/\/ \u56e0\u4e3a\u672c\u5730\u5b57\u8282\u5e8f\u548c\u7f51\u7edc\u5b57\u8282\u5e8f\u4e0d\u4e00\u5b9a\u4e00\u81f4&#xff0c;\u6240\u4ee5\u7aef\u53e3\u53f7\u5728\u8fdb\u5165\u7f51\u7edc\u4e4b\u524d&#xff0c;\u4e00\u5b9a\u8981\u8f6c\u6362\u6210\u5927\u7aef\u5b57\u8282\u5e8f<br \/>\n    addr.sin_addr.s_addr &#061; inet_addr(&#034;192.168.1.1&#034;);<br \/>\n    if(bind(server,(struct sockaddr*)&amp;addr,sizeof(addr)) &#061;&#061; -1){<br \/>\n        perror(&#034;bind&#034;);<br \/>\n    } <\/p>\n<h3 id=\"BJQt-1742299188349\">1.4 \u5982\u4f55\u4f7f\u7528\u5957\u63a5\u5b57\u6587\u4ef6\u4f20\u8f93\u6570\u636e<\/h3>\n<h4 id=\"AEm4-1742299188355\">1.4.1 \u76f4\u63a5\u4f7f\u7528 read \u6216\u8005 write \u51fd\u6570<\/h4>\n<p>\u6587\u4ef6IO\u91cc\u9762\u7684read \u548c write \u600e\u4e48\u7528&#xff0c;\u5957\u63a5\u5b57\u7684read\u548cwrite\u5c31\u600e\u4e48\u7528<\/p>\n<p>\u4e0d\u518d\u4ecb\u7ecd<\/p>\n<h4 id=\"7yUO-1742299188361\">1.4.2 recv \u548c send<\/h4>\n<p>\u8fd92\u4e2a\u51fd\u6570\u4e13\u95e8\u7ed9\u5957\u63a5\u5b57\u4f7f\u7528\u7684&#xff0c;\u63cf\u8ff0\u7b26\u7528\u4e0d\u4e86<\/p>\n<p>\u51fd\u6570\u539f\u578b&#xff1a;ssize_t send(int sockfd, const void *buf, size_t len, int flags);<br \/>\n\u529f\u80fd\u63cf\u8ff0&#xff1a;\u901a\u8fc7\u5957\u63a5\u5b57&#xff0c;\u5c06\u6570\u636e\u53d1\u9001\u5230\u7f51\u7edc\u4e2d<br \/>\n\u53c2\u6570\u63cf\u8ff0&#xff1a;<br \/>\n    \u524d3\u4e2a\u53c2\u6570 sockfd\u3001buf\u3001len &#xff1a;\u529f\u80fd\u548cwrite\u4e00\u6a21\u4e00\u6837<br \/>\n    \u53c2\u6570 flags&#xff1a;\u8fd9\u4e2a\u53c2\u6570\u4e5f\u662fsend \u548c write \u7684\u533a\u522b\u6240\u5728<br \/>\n        flags \u53ef\u4ee5\u8bbe\u5b9a send \u662f\u4e00\u4e2a\u963b\u585e\u578b IO \u8fd8\u662f\u975e\u963b\u585e\u578b IO<br \/>\n            0&#xff1a;\u963b\u585e\u578bIO<br \/>\n            MSG_DONTWAIT&#xff1a;\u975e\u963b\u585e\u578bIO<br \/>\n            send\u4ec0\u4e48\u65f6\u5019\u963b\u585e&#xff1a;\u53d1\u9001\u6570\u636e\u76ee\u6807\u5730\u70b9&#xff0c;\u5982\u679c\u6ee1\u4e86&#xff0c;\u5219send\u4f1a\u963b\u585e&#xff0c;\u76f4\u5230\u76ee\u6807\u5730\u70b9\u4ea7\u751f\u65b0\u7684\u7a7a\u95f4\u4e3a\u6b62\u3001<\/p>\n<p>\u6240\u4ee5\u4ece\u6211\u4eec\u7684\u89d2\u5ea6\u6765\u770b&#xff1a;send \u548cwrite \u552f\u4e00\u7684\u533a\u522b\u5728\u4e8e<br \/>\n    send \u81ea\u5e26\u8bbe\u7f6e\u963b\u585e\u548c\u975e\u963b\u585e\u7684\u53c2\u6570<br \/>\n    write \u4e0d\u81ea\u5e26\u8fd9\u4e2a\u529f\u80fd&#xff0c;\u9ed8\u8ba4\u963b\u585e<\/p>\n<p>\u51fd\u6570\u539f\u578b&#xff1a;ssize_t recv(int sockfd, void *buf, size_t len, int flags);<br \/>\n\u529f\u80fd\u63cf\u8ff0&#xff1a;\u901a\u8fc7\u5957\u63a5\u5b57&#xff0c;\u4ece\u7f51\u7edc\u4e2d\u8bfb\u53d6\u6570\u636e<br \/>\n\u53c2\u6570\u63cf\u8ff0&#xff1a;<br \/>\n    \u524d3\u4e2a\u53c2\u6570 sockfd\u3001buf\u3001len &#xff1a;\u529f\u80fd\u548cread\u4e00\u6a21\u4e00\u6837<br \/>\n    \u53c2\u6570 flags&#xff1a;\u8fd9\u4e2a\u53c2\u6570\u4e5f\u662fsend \u548c write \u7684\u533a\u522b\u6240\u5728<br \/>\n    flags \u53ef\u4ee5\u8bbe\u5b9a send \u662f\u4e00\u4e2a\u963b\u585e\u578b IO \u8fd8\u662f\u975e\u963b\u585e\u578b IO<br \/>\n        0&#xff1a;\u963b\u585e\u578bIO<br \/>\n        MSG_DONTWAIT&#xff1a;\u975e\u963b\u585e\u578bIO    <\/p>\n<p>\u6240\u4ee5\u4ece\u6211\u4eec\u7684\u89d2\u5ea6\u6765\u770b&#xff1a;recv \u548c read \u552f\u4e00\u533a\u522b\u5728\u4e8e<br \/>\n    recv \u81ea\u5e26\u8bbe\u7f6e\u963b\u585e\u548c\u975e\u963b\u585e\u7684\u53c2\u6570<br \/>\n    read \u4e0d\u81ea\u5e26&#xff0c;\u9ed8\u8ba4\u963b\u585e <\/p>\n<h3 id=\"e6Pu-1742299188422\">1.5 \u5982\u4f55\u5c06\u4efb\u610f\u4e00\u4e2a\u963b\u585e\u578bIO\u51fd\u6570&#xff0c;\u8bbe\u7f6e\u6210\u975e\u963b\u585e\u7684<\/h3>\n<p>\u51fd\u6570\u539f\u578b&#xff1a;int fcntl(int fd, int cmd, &#8230; \/* arg *\/ );<br \/>\n\u529f\u80fd\u63cf\u8ff0&#xff1a;\u8be5\u51fd\u6570\u6709\u591a\u4e2a\u529f\u80fd&#xff0c;\u5230\u5e95\u6267\u884c\u54ea\u4e2a\u529f\u80fd\u7531 cmd \u7684\u503c\u51b3\u5b9a<br \/>\n\u53c2\u6570\u63cf\u8ff0&#xff1a;<br \/>\n    \u53c2\u6570 cmd &#xff1a;<br \/>\n         F_GETFL&#xff1a;\u83b7\u53d6 fd \u63cf\u8ff0\u7b26\u7684 flag<br \/>\n         F_SETFL&#xff1a;\u8bbe\u7f6e fd \u63cf\u8ff0\u7b26\u7684 flag<br \/>\n             \u5f53cmd\u9009\u62e9F_SETFL\u7684\u65f6\u5019&#xff0c;\u9700\u8981\u4f20\u5165\u7b2c3\u4e2a\u53c2\u6570&#xff0c;\u7b2c\u4e09\u4e2a\u53c2\u6570\u529f\u80fd\u4e3a \u60f3\u8981\u8bbe\u7f6e\u7684\u5177\u4f53\u7684flag\u7684\u503c<br \/>\n    \u5230\u5e95\u4ec0\u4e48\u662fflag&#xff1a;\u5176\u5b9e\u5c31\u662fopen\u51fd\u6570\u7b2c2\u4e2a\u53c2\u6570 flag&#xff0c;\u4e5f\u5c31\u662f\u6587\u4ef6\u63cf\u8ff0\u7b26\u5c5e\u6027<br \/>\n        \u5c5e\u6027\u6709&#xff1a;\u53ef\u8bfb&#xff0c;\u53ef\u5199&#xff0c;\u8ffd\u52a0&#xff0c;\u6e05\u7a7a&#xff0c;\u521b\u5efa&#xff0c;\u975e\u963b\u585e \u7b49\u7b49\u7b49\u7b49<\/p>\n<p>\u4ee5scanf\u4e3a\u4f8b&#xff1a;\u901a\u8fc7fcntl\u51fd\u6570\u5c06\u6807\u51c6\u8f93\u5165\u6d41\u4fee\u6539\u6210\u975e\u963b\u585e\u578bIO<br \/>\n    scanf \u7528\u7684\u662f stdin \u6807\u51c6\u8f93\u5165\u6d41&#xff0c;\u963b\u585e\u578bIO<br \/>\n    \u4e00\u65e6\u5c06\u6807\u51c6\u8f93\u5165\u6d41\u4fee\u6539\u6210\u975e\u963b\u585e\u578bIO\u4e4b\u540e&#xff0c;scanf\u5c31\u4e0d\u963b\u585e\u4e86 <\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"350\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418133741-680255a595fec.png\" width=\"510\" \/><\/p>\n<h2>\u4e8c\u3001\u521b\u5efa\u670d\u52a1\u5668<\/h2>\n<h3 id=\"44uT-1742299215914\">2.1 \u670d\u52a1\u5668\u7684\u642d\u5efa<\/h3>\n<h4 id=\"h9jF-1742299215916\">2.1.1 \u521b\u5efa\u670d\u52a1\u5668\u5957\u63a5\u5b57&#xff1a;socket<\/h4>\n<h4 id=\"FB7C-1742299215918\">2.1.2 \u63d0\u524d\u51c6\u5907ip\u548cport:struct sockaddr_in addr<\/h4>\n<h4 id=\"lFwd-1742299215920\">2.1.3 \u4e3a\u670d\u52a1\u5668\u5957\u63a5\u5b57\u7ed1\u5b9aip\u548cport &#xff1a;bind<\/h4>\n<h4 id=\"HBpm-1742299215923\">2.1.4 \u521b\u5efa\u4e00\u4e2a\u76d1\u542c\u5217\u8868&#xff1a;listen<\/h4>\n<p>\u6240\u6709\u8fde\u63a5\u670d\u52a1\u5668\u7684\u5ba2\u6237\u7aef&#xff0c;\u90fd\u4f1a\u88ab\u670d\u52a1\u5668\u52a0\u5165\u5230\u76d1\u542c\u5217\u8868\u4e2d\u53bb<\/p>\n<p>\u51fd\u6570\u539f\u578b&#xff1a;int listen(int sockfd, int backlog);<br \/>\n\u529f\u80fd\u63cf\u8ff0&#xff1a;\u521b\u5efa\u76d1\u542c\u5217\u8868\u5e76\u76d1\u542c\u5ba2\u6237\u7aef\u8fde\u63a5&#xff0c;\u5982\u679c\u6709\u5ba2\u6237\u7aef\u8fde\u63a5&#xff0c;\u5219\u5c06\u8be5\u5ba2\u6237\u7aef\u52a0\u5165\u76d1\u542c\u5217\u8868\u4e2d<br \/>\n\u53c2\u6570\u63cf\u8ff0&#xff1a;<br \/>\n    \u53c2\u6570 sockfd&#xff1a;\u54ea\u4e2a\u63cf\u8ff0\u7b26\u9700\u8981\u76d1\u542c\u5e76\u521b\u5efa\u76d1\u542c\u5217\u8868&#xff0c;\u4e00\u822c\u5c31\u662f\u670d\u52a1\u5668\u7684\u63cf\u8ff0\u7b26<br \/>\n    \u53c2\u6570 backlog&#xff1a;\u76d1\u542c\u5217\u8868\u7684\u5927\u5c0f<\/p>\n<h4 id=\"j9FO-1742299215940\">2.1.5 \u4ece\u76d1\u542c\u5217\u8868\u4e2d&#xff0c;\u63a5\u53d7\u5ba2\u6237\u7aef\u7684\u8fde\u63a5:accept<\/h4>\n<p>\u51fd\u6570\u539f\u578b&#xff1a;int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen);<br \/>\n\u529f\u80fd\u63cf\u8ff0&#xff1a;\u63a5\u53d7\u5ba2\u6237\u7aef\u7684\u8fde\u63a5&#xff0c;\u5e76\u4e14\u83b7\u53d6\u8be5\u5ba2\u6237\u7aef\u7684ip\u548cport<br \/>\n\u53c2\u6570\u63cf\u8ff0&#xff1a;<br \/>\n    \u53c2\u6570 sockfd&#xff1a;\u54ea\u4e2a\u63cf\u8ff0\u7b26\u63a5\u53d7\u5ba2\u6237\u7aef\u7684\u8fde\u63a5&#xff0c;\u4e00\u822c\u5c31\u662f\u670d\u52a1\u5668<br \/>\n    \u53c2\u6570 addr&#xff1a;\u4e00\u4e2a\u5730\u5740\u4fe1\u606f\u7ed3\u6784\u4f53\u7684\u5730\u5740&#xff0c;\u8be5\u7ed3\u6784\u4f53\u4e2d\u5c06\u4f1a\u63a5\u53d7\u5e76\u5b58\u653e\u65b0\u94fe\u63a5\u7684\u5ba2\u6237\u7aef\u7684ip\u548cport<br \/>\n    \u53c2\u6570 addrlen&#xff1a;\u7b2c\u4e8c\u4e2a\u53c2\u6570\u7684\u5b9e\u9645\u957f\u5ea6&#xff0c;\u4f46\u662f\u6ce8\u610f\u8fd9\u91cc\u662f\u4e2a\u6307\u9488<\/p>\n<p>\u8fd4\u56de\u503c&#xff1a;\u6210\u529f\u63a5\u53d7\u5ba2\u6237\u7aef\u7684\u8fde\u63a5\u4e4b\u540e&#xff0c;\u4f1a\u8fd4\u56de\u8be5\u5ba2\u6237\u7aef\u7684\u5957\u63a5\u5b57<br \/>\n    \u5ba2\u6237\u7aef\u5957\u63a5\u5b57\u975e\u5e38\u6709\u7528&#xff0c;\u670d\u52a1\u5668\u4e0e\u7279\u5b9a\u7684\u5ba2\u6237\u7aef\u8fdb\u884c\u901a\u4fe1\u7684\u65f6\u5019&#xff0c;\u5fc5\u987b\u4f7f\u7528\u8be5\u5ba2\u6237\u7aef\u5957\u63a5\u5b57<\/p>\n<p>\u8c03\u7528\u5f62\u5f0f&#xff1a;<br \/>\n    struct sockaddr_in client_addr &#061; {0};<br \/>\n    int len &#061; sizeof(client_addr);<br \/>\n    int client &#061; accept(server,(struct sockaddr*)&amp;client_addr,&amp;len);<\/p>\n<p>\u5f53\u7136&#xff0c;\u6211\u4eec\u4e5f\u53ef\u4ee5\u4ec5\u63a5\u53d7\u5ba2\u6237\u7aef\u7684\u8fde\u63a5&#xff0c;\u4e0d\u9700\u8981\u77e5\u9053\u5ba2\u6237\u7aef\u7684ip\u548cport<br \/>\n    int client &#061; accept(server,NULL,NULL);<\/p>\n<p>\u6ce8\u610f&#xff1a;accept \u51fd\u6570\u662f\u4e00\u4e2a\u963b\u585e\u578b\u51fd\u6570<br \/>\n    \u4e5f\u5c31\u662f\u8bf4&#xff0c;\u4e00\u65e6\u8c03\u7528accept\u51fd\u6570\u5c31\u4f1a\u7acb\u523b\u963b\u585e&#xff0c;\u76f4\u5230\u6709\u5ba2\u6237\u7aef\u8fde\u63a5\u4e3a\u6b62<\/p>\n<h4 id=\"LmPh-1742299215985\">2.1.6 \u670d\u52a1\u5668\u4ee3\u7801<\/h4>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"695\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418133741-680255a5ac854.png\" width=\"646\" \/><\/p>\n<h2>\u4e09\u3001\u521b\u5efa\u5ba2\u6237\u7aef<\/h2>\n<h3 id=\"toLI-1742299215988\">3.1\u00a0\u5ba2\u6237\u7aef\u7684\u642d\u5efa<\/h3>\n<h3 id=\"hFaX-1742299215990\">3.1 \u521b\u5efa\u5ba2\u6237\u7aef\u5957\u63a5\u5b57 :socket<\/h3>\n<h3 id=\"fUAi-1742299215992\">3.2 \u4e3a\u5ba2\u6237\u7aef\u51c6\u5907 ip \u548c port &#xff1a;struct sockaddr_in addr<\/h3>\n<h3 id=\"zweO-1742299215994\">3.3 \u8fde\u63a5\u670d\u52a1\u5668&#xff1a;connect<\/h3>\n<p>\u51fd\u6570\u539f\u578b&#xff1a;int connect(int sockfd, const struct sockaddr *addr,socklen_t addrlen);<br \/>\n\u529f\u80fd\u63cf\u8ff0&#xff1a;\u6839\u636e\u63d0\u4f9b\u7684ip\u548cport\u8fde\u63a5\u5230\u6307\u5b9a\u670d\u52a1\u5668<br \/>\n\u53c2\u6570\u63cf\u8ff0&#xff1a;<br \/>\n    \u53c2\u6570 sockfd&#xff1a;\u5ba2\u6237\u7aef\u5957\u63a5\u5b57<br \/>\n    \u53c2\u6570 addr&#xff1a;\u5b58\u6709ip\u548cport\u7684\u4e00\u4e2a\u901a\u7528\u5730\u5740\u4fe1\u606f\u7ed3\u6784\u4f53<br \/>\n    \u53c2\u6570 addrlen&#xff1a;\u7b2c2\u4e2a\u53c2\u6570\u7684\u5b9e\u9645\u957f\u5ea6<br \/>\n\u8fd4\u56de\u503c&#xff1a;\u6210\u529f\u8fde\u63a5\u8fd4\u56de0&#xff0c;\u5931\u8d25\u8fd4\u56de-1&#xff0c;\u56e0\u4e3a\u5b58\u5728\u5931\u8d25\u7684\u53ef\u80fd&#xff0c;\u6240\u4ee5\u8bb0\u5f97\u5224\u7a7a<\/p>\n<p>\u8c03\u7528\u5f62\u5f0f<br \/>\n    struct sockaddr_in addr &#061; {0};<br \/>\n    addr.sin_family &#061; AF_INET;<br \/>\n    addr.sin_port &#061; htons(8888); \/\/ \u56e0\u4e3a\u672c\u5730\u5b57\u8282\u5e8f\u548c\u7f51\u7edc\u5b57\u8282\u5e8f\u4e0d\u4e00\u5b9a\u4e00\u81f4&#xff0c;\u6240\u4ee5\u7aef\u53e3\u53f7\u5728\u8fdb\u5165\u7f51\u7edc\u4e4b\u524d&#xff0c;\u4e00\u5b9a\u8981\u8f6c\u6362\u6210\u5927\u7aef\u5b57\u8282\u5e8f<br \/>\n    addr.sin_addr.s_addr &#061; inet_addr(&#034;192.168.1.1&#034;);<br \/>\n    if(connect(server,(struct sockaddr*)&amp;addr,sizeof(addr)) &#061;&#061; -1){<br \/>\n        perror(&#034;bind&#034;);<br \/>\n    } <\/p>\n<h3 id=\"GHJO-1742299216034\">3.4 \u5ba2\u6237\u7aef\u65ad\u5f00\u8fde\u63a5<\/h3>\n<p>\u5ba2\u6237\u7aef\u4e00\u65e6\u4e0e\u670d\u52a1\u5668\u65ad\u5f00\u94fe\u63a5\u4e4b\u540e<\/p>\n<p>\u670d\u52a1\u5668\u90a3\u8fb9&#xff0c;\u901a\u8fc7\u5ba2\u6237\u7aef\u5957\u63a5\u5b57\u8bfb\u53d6\u5ba2\u6237\u7aef\u53d1\u9001\u6570\u636e\u7684read\u6216\u8005recv\u51fd\u6570&#xff0c;\u5c31\u4f1a\u4ece\u963b\u585e\u53d8\u6210\u975e\u963b\u585e<\/p>\n<p>\u53d8\u6210\u975e\u963b\u585e\u4e4b\u540e&#xff0c;\u5982\u679c\u6ca1\u6709\u8bfb\u53d6\u5230\u6570\u636e&#xff0c;\u5219\u4f1a\u8fd4\u56de0<\/p>\n<p>\u6240\u4ee5\u6211\u4eec\u53ef\u4ee5\u6839\u636eread\u6216\u8005recv\u7684\u8fd4\u56de\u503c\u6765\u5224\u65ad\u5ba2\u6237\u7aef\u662f\u5426\u65ad\u5f00\u8fde\u63a5<\/p>\n<h3 id=\"ZER6-1742299216046\">3.5 \u5ba2\u6237\u7aef\u4ee3\u7801<\/h3>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"609\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418133741-680255a5ca986.png\" width=\"720\" \/><\/p>\n<h2>\u56db\u3001TCP\u4e2d\u7684\u7c98\u5305\u73b0\u8c61<\/h2>\n<p>tcp\u534f\u8bae\u4e3a\u4e86\u63d0\u9ad8\u53d1\u9001\u7684\u6548\u7387&#xff0c;\u4f1a\u5c06\u77ed\u65f6\u95f4\u8fde\u7eed\u53d1\u9001\u7684\u5c0f\u6570\u636e&#xff0c;\u5f53\u505a\u4e00\u7ec4\u6570\u636e\u7edf\u4e00\u53d1\u9001<\/p>\n<p id=\"lwud-1742299216059\">\u539f\u7406\u662f&#xff1a;<\/p>\n<p>tcp\u534f\u8bae\u672c\u8eab\u5b58\u5728\u4e00\u4e2a1500\u5b57\u8282\u7684\u7f13\u5b58\u533a&#xff0c;tcp\u534f\u8bae\u6bcf\u6b21write\u53d1\u9001\u6570\u636e\u7684\u65f6\u5019&#xff0c;\u603b\u662f\u4f1a\u53d1\u90011500\u4e2a\u5b57\u8282<\/p>\n<p>\u5982\u679c\u53d1\u9001\u4e86n\u7ec4\u6570\u636e&#xff0c;\u8fd9n\u7ec4\u6570\u636e\u7684\u65f6\u95f4\u95f4\u9694\u5f88\u77ed&#xff0c;\u5e76\u4e14\u6570\u636e\u603b\u5927\u5c0f\u6ca1\u6709\u8d85\u8fc71500\u4e2a\u5b57\u8282<\/p>\n<p>\u90a3\u4e48TCP\u534f\u8bae\u5c31\u4f1a\u5c06\u8fd9n\u7ec4\u6570\u636e\u5168\u90fd\u653e\u5230\u540c\u4e00\u4e2a1500\u5b57\u8282\u7684\u7f13\u5b58\u533a\u4e2d\u53bb&#xff0c;\u7edf\u4e00\u53d1\u9001<\/p>\n<h2 id=\"bOXn-1742299216070\">4.1 \u534f\u8bae\u5305<\/h2>\n<p>\u89c4\u5b9a\u597d\u4e00\u7ec4\u6570\u636e\u7684\u56fa\u5b9a\u5927\u5c0f&#xff0c;\u4ee5\u53ca\u4e00\u7ec4\u6570\u636e\u91cc\u9762\u6bcf\u4e2a\u6570\u636e\u5360\u636e\u591a\u5c11\u4e2a\u5b57\u8282<\/p>\n<p>\u7136\u540e\u670d\u52a1\u5668\u548c\u5ba2\u6237\u7aef&#xff0c;\u5168\u90fd\u9075\u5faa\u540c\u6837\u7684\u89c4\u5b9a\u5b9e\u73b0\u6570\u636e\u7684\u6536\u53d1<\/p>\n<p>\u8fd9\u6837\u7684\u89c4\u5b9a\u5982\u679c\u6211\u4eec\u628a\u5b83\u6253\u5305\u5199\u6210\u5177\u4f53\u7684\u4ee3\u7801&#xff0c;\u6253\u5305\u51fa\u6765\u7684\u6210\u679c\u6211\u4eec\u5c31\u79f0\u4e3a\u534f\u8bae\u5305<\/p>\n<h3 id=\"unR0-1742299216078\">4.1.1 \u4f7f\u7528\u534f\u8bae\u5305\u7684\u670d\u52a1\u5668<\/h3>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1133\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418133741-680255a5e8348.png\" width=\"818\" \/><\/p>\n<h3 id=\"ZqOV-1742299216081\">4.1.2 \u4f7f\u7528\u534f\u8bae\u5305\u7684\u5ba2\u6237\u7aef<\/h3>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1102\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418133742-680255a65a842.png\" width=\"829\" \/><\/p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.1k\u6b21\uff0c\u70b9\u8d5e12\u6b21\uff0c\u6536\u85cf25\u6b21\u3002\u5957\u63a5\u5b57\u6587\u4ef6\uff0c\u539f\u672c\u5c31\u662f\u4e00\u4e2a\u548c\u7ba1\u9053\u6587\u4ef6\u7c7b\u4f3c\uff0c\u7528\u6765\u5b9e\u73b0\u8fdb\u7a0b\u95f4\u901a\u4fe1\u7684\u4e00\u4e2a\u6587\u4ef6\u65e2\u7136\u6709\u4e86\u7ba1\u9053\u6587\u4ef6\uff0c\u5f53\u65f6\u4e3a\u4ec0\u4e48\u8fd8\u8981\u5f00\u53d1\u5957\u63a5\u5b57\u6587\u4ef6\uff0c\u53bb\u5b9e\u73b0\u8fdb\u7a0b\u7684\u901a\u4fe1\u56e0\u4e3a\u7ba1\u9053\u6587\u4ef6\u662f\u534a\u53cc\u5de5\u6a21\u5f0f\u7684\u5957\u63a5\u5b57\u6587\u4ef6\u662f\u5168\u53cc\u5de5\u6a21\u5f0f\u7684\u4f46\u662f\u540e\u6765\uff0c\u6709\u4e86OSI 7\u5c42\u6a21\u578b\u4ee5\u53caTCP\u534f\u8bae 4\u5c42\u6a21\u578b\u4e4b\u540e\u5957\u63a5\u5b57\u6587\u4ef6\u5c31\u8fdb\u5316\u51fa\u4e86\u65b0\u7684\u529f\u80fd\uff1a\u5957\u63a5\u5b57\u6587\u4ef6\u4e2d\u5141\u8bb8\u5b58\u653e ip \u548c port \u4ee5\u5b9e\u73b0\u6570\u636e\u7684\u8de8\u4e3b\u673a\u4f20\u8f93\u539f\u5148\u53ea\u80fd\u5b9e\u73b0\u8fdb\u7a0b\u95f4\u901a\u4fe1\u7684\u5957\u63a5\u5b57\uff0c\u5c31\u6709\u4e86\u4e00\u4e2a\u65b0\u7684\u540d\u5b57\uff1a\u57df\u5957\u63a5\u5b57\u3002_\u5957\u63a5\u5b57 \u670d\u52a1\u5668 \u5ba2\u6237\u7aef \u56fe<\/p>\n","protected":false},"author":2,"featured_media":14985,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[270,43,78],"topic":[],"class_list":["post-14991","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-270","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>\u7f51\u7edc\u7f16\u7a0b\u2014\u2014\u5957\u63a5\u5b57\u3001\u521b\u5efa\u670d\u52a1\u5668\u3001\u521b\u5efa\u5ba2\u6237\u7aef - \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\/14991.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u7f51\u7edc\u7f16\u7a0b\u2014\u2014\u5957\u63a5\u5b57\u3001\u521b\u5efa\u670d\u52a1\u5668\u3001\u521b\u5efa\u5ba2\u6237\u7aef - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.1k\u6b21\uff0c\u70b9\u8d5e12\u6b21\uff0c\u6536\u85cf25\u6b21\u3002\u5957\u63a5\u5b57\u6587\u4ef6\uff0c\u539f\u672c\u5c31\u662f\u4e00\u4e2a\u548c\u7ba1\u9053\u6587\u4ef6\u7c7b\u4f3c\uff0c\u7528\u6765\u5b9e\u73b0\u8fdb\u7a0b\u95f4\u901a\u4fe1\u7684\u4e00\u4e2a\u6587\u4ef6\u65e2\u7136\u6709\u4e86\u7ba1\u9053\u6587\u4ef6\uff0c\u5f53\u65f6\u4e3a\u4ec0\u4e48\u8fd8\u8981\u5f00\u53d1\u5957\u63a5\u5b57\u6587\u4ef6\uff0c\u53bb\u5b9e\u73b0\u8fdb\u7a0b\u7684\u901a\u4fe1\u56e0\u4e3a\u7ba1\u9053\u6587\u4ef6\u662f\u534a\u53cc\u5de5\u6a21\u5f0f\u7684\u5957\u63a5\u5b57\u6587\u4ef6\u662f\u5168\u53cc\u5de5\u6a21\u5f0f\u7684\u4f46\u662f\u540e\u6765\uff0c\u6709\u4e86OSI 7\u5c42\u6a21\u578b\u4ee5\u53caTCP\u534f\u8bae 4\u5c42\u6a21\u578b\u4e4b\u540e\u5957\u63a5\u5b57\u6587\u4ef6\u5c31\u8fdb\u5316\u51fa\u4e86\u65b0\u7684\u529f\u80fd\uff1a\u5957\u63a5\u5b57\u6587\u4ef6\u4e2d\u5141\u8bb8\u5b58\u653e ip \u548c port \u4ee5\u5b9e\u73b0\u6570\u636e\u7684\u8de8\u4e3b\u673a\u4f20\u8f93\u539f\u5148\u53ea\u80fd\u5b9e\u73b0\u8fdb\u7a0b\u95f4\u901a\u4fe1\u7684\u5957\u63a5\u5b57\uff0c\u5c31\u6709\u4e86\u4e00\u4e2a\u65b0\u7684\u540d\u5b57\uff1a\u57df\u5957\u63a5\u5b57\u3002_\u5957\u63a5\u5b57 \u670d\u52a1\u5668 \u5ba2\u6237\u7aef \u56fe\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/14991.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-18T13:37:43+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418133740-680255a4b4118.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=\"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\/14991.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/14991.html\",\"name\":\"\u7f51\u7edc\u7f16\u7a0b\u2014\u2014\u5957\u63a5\u5b57\u3001\u521b\u5efa\u670d\u52a1\u5668\u3001\u521b\u5efa\u5ba2\u6237\u7aef - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-04-18T13:37:43+00:00\",\"dateModified\":\"2025-04-18T13:37:43+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/14991.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/14991.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/14991.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u7f51\u7edc\u7f16\u7a0b\u2014\u2014\u5957\u63a5\u5b57\u3001\u521b\u5efa\u670d\u52a1\u5668\u3001\u521b\u5efa\u5ba2\u6237\u7aef\"}]},{\"@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":"\u7f51\u7edc\u7f16\u7a0b\u2014\u2014\u5957\u63a5\u5b57\u3001\u521b\u5efa\u670d\u52a1\u5668\u3001\u521b\u5efa\u5ba2\u6237\u7aef - \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\/14991.html","og_locale":"zh_CN","og_type":"article","og_title":"\u7f51\u7edc\u7f16\u7a0b\u2014\u2014\u5957\u63a5\u5b57\u3001\u521b\u5efa\u670d\u52a1\u5668\u3001\u521b\u5efa\u5ba2\u6237\u7aef - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.1k\u6b21\uff0c\u70b9\u8d5e12\u6b21\uff0c\u6536\u85cf25\u6b21\u3002\u5957\u63a5\u5b57\u6587\u4ef6\uff0c\u539f\u672c\u5c31\u662f\u4e00\u4e2a\u548c\u7ba1\u9053\u6587\u4ef6\u7c7b\u4f3c\uff0c\u7528\u6765\u5b9e\u73b0\u8fdb\u7a0b\u95f4\u901a\u4fe1\u7684\u4e00\u4e2a\u6587\u4ef6\u65e2\u7136\u6709\u4e86\u7ba1\u9053\u6587\u4ef6\uff0c\u5f53\u65f6\u4e3a\u4ec0\u4e48\u8fd8\u8981\u5f00\u53d1\u5957\u63a5\u5b57\u6587\u4ef6\uff0c\u53bb\u5b9e\u73b0\u8fdb\u7a0b\u7684\u901a\u4fe1\u56e0\u4e3a\u7ba1\u9053\u6587\u4ef6\u662f\u534a\u53cc\u5de5\u6a21\u5f0f\u7684\u5957\u63a5\u5b57\u6587\u4ef6\u662f\u5168\u53cc\u5de5\u6a21\u5f0f\u7684\u4f46\u662f\u540e\u6765\uff0c\u6709\u4e86OSI 7\u5c42\u6a21\u578b\u4ee5\u53caTCP\u534f\u8bae 4\u5c42\u6a21\u578b\u4e4b\u540e\u5957\u63a5\u5b57\u6587\u4ef6\u5c31\u8fdb\u5316\u51fa\u4e86\u65b0\u7684\u529f\u80fd\uff1a\u5957\u63a5\u5b57\u6587\u4ef6\u4e2d\u5141\u8bb8\u5b58\u653e ip \u548c port \u4ee5\u5b9e\u73b0\u6570\u636e\u7684\u8de8\u4e3b\u673a\u4f20\u8f93\u539f\u5148\u53ea\u80fd\u5b9e\u73b0\u8fdb\u7a0b\u95f4\u901a\u4fe1\u7684\u5957\u63a5\u5b57\uff0c\u5c31\u6709\u4e86\u4e00\u4e2a\u65b0\u7684\u540d\u5b57\uff1a\u57df\u5957\u63a5\u5b57\u3002_\u5957\u63a5\u5b57 \u670d\u52a1\u5668 \u5ba2\u6237\u7aef \u56fe","og_url":"https:\/\/www.wsisp.com\/helps\/14991.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-04-18T13:37:43+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418133740-680255a4b4118.png"}],"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\/14991.html","url":"https:\/\/www.wsisp.com\/helps\/14991.html","name":"\u7f51\u7edc\u7f16\u7a0b\u2014\u2014\u5957\u63a5\u5b57\u3001\u521b\u5efa\u670d\u52a1\u5668\u3001\u521b\u5efa\u5ba2\u6237\u7aef - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-04-18T13:37:43+00:00","dateModified":"2025-04-18T13:37:43+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/14991.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/14991.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/14991.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u7f51\u7edc\u7f16\u7a0b\u2014\u2014\u5957\u63a5\u5b57\u3001\u521b\u5efa\u670d\u52a1\u5668\u3001\u521b\u5efa\u5ba2\u6237\u7aef"}]},{"@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\/14991","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=14991"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/14991\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/14985"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=14991"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=14991"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=14991"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=14991"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}