{"id":28482,"date":"2025-04-20T00:36:18","date_gmt":"2025-04-19T16:36:18","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/28482.html"},"modified":"2025-04-20T00:36:18","modified_gmt":"2025-04-19T16:36:18","slug":"%e3%80%90esp32%e3%80%91esp-idf%e5%bc%80%e5%8f%91-wifi%e5%bc%80%e5%8f%91-tcp%e4%bc%a0%e8%be%93%e6%8e%a7%e5%88%b6%e5%8d%8f%e8%ae%ae-tcp%e6%9c%8d%e5%8a%a1%e5%99%a8%e5%92%8c%e5%ae%a2%e6%88%b7","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/28482.html","title":{"rendered":"\u3010ESP32\u3011ESP-IDF\u5f00\u53d1 | WiFi\u5f00\u53d1 | TCP\u4f20\u8f93\u63a7\u5236\u534f\u8bae + TCP\u670d\u52a1\u5668\u548c\u5ba2\u6237\u7aef\u4f8b\u7a0b"},"content":{"rendered":"<h2>1. \u7b80\u4ecb<\/h2>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0TCP&#xff08;Transmission Control Protocol&#xff09;&#xff0c;\u5168\u79f0\u4f20\u8f93\u63a7\u5236\u534f\u8bae\u3002\u5b83\u7684\u7279\u70b9\u6709\u4ee5\u4e0b\u51e0\u70b9&#xff1a;\u9762\u5411\u8fde\u63a5&#xff0c;\u6bcf\u4e00\u4e2aTCP\u8fde\u63a5\u53ea\u80fd\u662f\u70b9\u5bf9\u70b9\u7684&#xff08;\u4e00\u5bf9\u4e00&#xff09;&#xff1b;\u63d0\u4f9b\u53ef\u9760\u4ea4\u4ed8\u670d\u52a1&#xff1b;\u63d0\u4f9b\u5168\u53cc\u5de5\u901a\u4fe1&#xff1b;\u9762\u5411\u5b57\u8282\u6d41\u3002<\/p>\n<h3>1.1 \u4e09\u6b21\u63e1\u624b<\/h3>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u4e09\u6b21\u63e1\u624b\u4ee3\u8868\u7684\u662fTCP\u7684\u8fde\u63a5\u8fc7\u7a0b&#xff0c;\u5b83\u8868\u793a\u5728\u6210\u529f\u8fde\u63a5\u4e4b\u524d&#xff0c;\u670d\u52a1\u7aef\u548c\u5ba2\u6237\u7aef\u9700\u8981\u901a\u4fe1\u4e09\u6b21\u624d\u80fd\u6700\u7ec8\u786e\u8ba4\u3002<\/p>\n<ul>\n<li>\u7b2c\u4e00\u6b21\u63e1\u624b&#xff1a;\u5ba2\u6237\u7aef\u5c06\u6807\u5fd7\u4f4dSYN\u7f6e\u4e3a1&#xff0c;\u968f\u673a\u4ea7\u751f\u4e00\u4e2a\u503cseq&#061;J&#xff0c;\u5e76\u5c06\u8be5\u6570\u636e\u5305\u53d1\u9001\u7ed9\u670d\u52a1\u5668\u7aef&#xff0c;\u5ba2\u6237\u7aef\u8fdb\u5165SYN_SENT\u72b6\u6001&#xff0c;\u7b49\u5f85\u670d\u52a1\u5668\u7aef\u786e\u8ba4&#xff1b;<\/li>\n<li>\u7b2c\u4e8c\u6b21\u63e1\u624b&#xff1a;\u670d\u52a1\u5668\u7aef\u6536\u5230\u6570\u636e\u5305\u540e\u7531\u6807\u5fd7\u4f4dSYN&#061;1\u77e5\u9053\u5ba2\u6237\u7aef\u8bf7\u6c42\u5efa\u7acb\u8fde\u63a5&#xff0c;\u670d\u52a1\u5668\u7aef\u5c06\u6807\u5fd7\u4f4dSYN\u548cACK\u90fd\u7f6e\u4e3a1&#xff0c;ack&#061;J&#043;1&#xff0c;\u968f\u673a\u4ea7\u751f\u4e00\u4e2a\u503cseq&#061;K&#xff0c;\u5e76\u5c06\u8be5\u6570\u636e\u5305\u53d1\u9001\u7ed9\u5ba2\u6237\u7aef\u4ee5\u786e\u8ba4\u8fde\u63a5\u8bf7\u6c42&#xff0c;\u670d\u52a1\u5668\u7aef\u8fdb\u5165SYN_RCVD\u72b6\u6001&#xff1b;<\/li>\n<li>\u00a0\u7b2c\u4e09\u6b21\u63e1\u624b&#xff1a;\u5ba2\u6237\u7aef\u6536\u5230\u786e\u8ba4\u540e&#xff0c;\u68c0\u67e5ack\u662f\u5426\u4e3aJ&#043;1&#xff0c;ACK\u662f\u5426\u4e3a1&#xff0c;\u5982\u679c\u6b63\u786e\u5219\u5c06\u6807\u5fd7\u4f4dACK\u7f6e\u4e3a1&#xff0c;ack&#061;K&#043;1&#xff0c;\u5e76\u5c06\u8be5\u6570\u636e\u5305\u53d1\u9001\u7ed9\u670d\u52a1\u5668\u7aef&#xff0c;\u670d\u52a1\u5668\u7aef\u68c0\u67e5ack\u662f\u5426\u4e3aK&#043;1&#xff0c;ACK\u662f\u5426\u4e3a1&#xff0c;\u5982\u679c\u6b63\u786e\u5219\u8fde\u63a5\u5efa\u7acb\u6210\u529f&#xff0c;\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u5668\u7aef\u8fdb\u5165ESTABLISHED\u72b6\u6001&#xff0c;\u5b8c\u6210\u4e09\u6b21\u63e1\u624b&#xff0c;\u968f\u540e\u5ba2\u6237\u7aef\u4e0e\u670d\u52a1\u5668\u7aef\u4e4b\u95f4\u53ef\u4ee5\u5f00\u59cb\u4f20\u8f93\u6570\u636e\u4e86\u3002<\/li>\n<\/ul>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"532\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250419163612-6803d0fcb3bee.png\" width=\"551\" \/><\/p>\n<h3>1.2 \u56db\u6b21\u6325\u624b<\/h3>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u56db\u6b21\u6325\u624b\u4ee3\u8868\u7684\u662fTCP\u7684\u65ad\u5f00\u8fde\u63a5\u8fc7\u7a0b&#xff0c;\u5b83\u8868\u793a\u5728\u6210\u529f\u65ad\u5f00\u524d&#xff0c;\u670d\u52a1\u7aef\u548c\u5ba2\u6237\u7aef\u9700\u8981\u901a\u4fe1\u56db\u6b21\u624d\u80fd\u6700\u7ec8\u786e\u8ba4\u3002<\/p>\n<ul>\n<li>\u7b2c\u4e00\u6b21\u6325\u624b&#xff1a;\u5ba2\u6237\u7aef\u53d1\u9001\u4e00\u4e2aFIN&#061;M&#xff0c;\u7528\u6765\u5173\u95ed\u5ba2\u6237\u7aef\u5230\u670d\u52a1\u5668\u7aef\u7684\u6570\u636e\u4f20\u9001&#xff0c;\u5ba2\u6237\u7aef\u8fdb\u5165FIN_WAIT_1\u72b6\u6001&#xff0c;\u8868\u793a\u5ba2\u6237\u7aef\u6ca1\u6709\u6570\u636e\u9700\u8981\u53d1\u9001\u4e86&#xff1b;\u4f46\u662f\u5982\u679c\u670d\u52a1\u5668\u7aef\u8fd8\u6709\u6570\u636e\u6ca1\u6709\u53d1\u9001\u5b8c\u6210&#xff0c;\u5219\u53ef\u4ee5\u7ee7\u7eed\u53d1\u9001\u6570\u636e&#xff1b;<\/li>\n<li>\u7b2c\u4e8c\u6b21\u6325\u624b&#xff1a;\u670d\u52a1\u5668\u7aef\u6536\u5230FIN\u540e&#xff0c;\u5148\u53d1\u9001ack&#061;M&#043;1&#xff0c;\u544a\u8bc9\u5ba2\u6237\u7aef\u8bf7\u6c42\u6536\u5230\u4e86&#xff0c;\u4f46\u662f\u6211\u8fd8\u6ca1\u51c6\u5907\u597d&#xff0c;\u8981\u7ee7\u7eed\u7b49\u5f85\u6211\u7684\u6d88\u606f&#xff1b;\u8fd9\u4e2a\u65f6\u5019\u5ba2\u6237\u7aef\u5c31\u8fdb\u5165FIN_WAIT_2 \u72b6\u6001&#xff0c;\u7ee7\u7eed\u7b49\u5f85\u670d\u52a1\u5668\u7aef\u7684FIN\u62a5\u6587&#xff1b;<\/li>\n<li>\u7b2c\u4e09\u6b21\u6325\u624b&#xff1a;\u5f53\u670d\u52a1\u5668\u7aef\u786e\u5b9a\u6570\u636e\u5df2\u53d1\u9001\u5b8c\u6210&#xff0c;\u5219\u5411\u5ba2\u6237\u7aef\u53d1\u9001FIN&#061;N\u62a5\u6587&#xff0c;\u544a\u8bc9\u5ba2\u6237\u7aef\u6570\u636e\u53d1\u5b8c\u4e86&#xff0c;\u51c6\u5907\u5173\u95ed\u8fde\u63a5&#xff1b;\u670d\u52a1\u5668\u7aef\u8fdb\u5165LAST_ACK\u72b6\u6001&#xff1b;<\/li>\n<li>\u7b2c\u56db\u6b21\u6325\u624b&#xff1a;\u5ba2\u6237\u7aef\u6536\u5230FIN&#061;N\u62a5\u6587\u540e&#xff0c;\u5c31\u77e5\u9053\u53ef\u4ee5\u5173\u95ed\u8fde\u63a5\u4e86&#xff0c;\u4f46\u662f\u4ed6\u8fd8\u662f\u4e0d\u76f8\u4fe1\u7f51\u7edc&#xff0c;\u6015\u670d\u52a1\u5668\u7aef\u4e0d\u77e5\u9053\u8981\u5173\u95ed&#xff0c;\u6240\u4ee5\u53d1\u9001ack&#061;N&#043;1\u540e\u4f1a\u8fdb\u5165TIME_WAIT\u72b6\u6001&#xff0c;\u5982\u679c\u670d\u52a1\u7aef\u6ca1\u6709\u6536\u5230ACK\u5219\u53ef\u4ee5\u91cd\u4f20\u3002\u670d\u52a1\u5668\u7aef\u6536\u5230ACK\u540e&#xff0c;\u5c31\u77e5\u9053\u53ef\u4ee5\u65ad\u5f00\u8fde\u63a5\u4e86\u3002\u5982\u679c\u5ba2\u6237\u7aef\u7b49\u5f85\u4e862MSL\u540e\u4f9d\u7136\u6ca1\u6709\u6536\u5230\u56de\u590d&#xff0c;\u5219\u8bc1\u660e\u670d\u52a1\u5668\u7aef\u5df2\u6b63\u5e38\u5173\u95ed&#xff0c;\u90a3\u5ba2\u6237\u7aef\u4e5f\u53ef\u4ee5\u5173\u95ed\u8fde\u63a5\u4e86\u3002<\/li>\n<\/ul>\n<p style=\"text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"426\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250419163612-6803d0fcdf646.png\" width=\"469\" \/>\u00a0<\/p>\n<h3>1.3 \u62e5\u585e\u63a7\u5236<\/h3>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u7f51\u7edc\u5c31\u50cf\u6211\u4eec\u751f\u6d3b\u4e2d\u7684\u4ea4\u901a\u7cfb\u7edf&#xff0c;\u5f53\u8f66\u6d41\u5927\u7684\u65f6\u5019\u5c31\u53ef\u80fd\u4f1a\u5bfc\u81f4\u62e5\u585e&#xff0c;TCP\u4e3a\u4e86\u4fdd\u8bc1\u53ef\u9760\u7684\u4ea4\u4ed8\u670d\u52a1&#xff0c;\u6240\u4ee5\u5f15\u5165\u4e86\u62e5\u585e\u63a7\u5236&#xff0c;\u7075\u6d3b\u8c03\u6574\u53d1\u9001\u7b56\u7565\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u62e5\u585e\u63a7\u5236\u662f\u4e00\u4e2a\u52a8\u6001\u7684\u8fc7\u7a0b&#xff0c;\u5b83\u65e2\u8981\u63d0\u9ad8\u5e26\u5bbd\u5229\u7528\u7387\u53d1\u9001\u5c3d\u91cf\u591a\u7684\u6570\u636e\u53c8\u8981\u907f\u514d\u7f51\u7edc\u62e5\u5835\u4e22\u5305RTT\u589e\u5927\u7b49\u95ee\u9898&#xff0c;\u57fa\u4e8e\u8fd9\u79cd\u9ad8\u8981\u6c42\u5e76\u4e0d\u662f\u5355\u4e00\u7b56\u7565\u53ef\u4ee5\u641e\u5b9a\u7684&#xff0c;\u56e0\u6b64TCP\u7684\u62e5\u585e\u63a7\u5236\u7b56\u7565\u5b9e\u9645\u4e0a\u662f\u5206\u9636\u6bb5\u5206\u7b56\u7565\u7684\u7efc\u5408\u8fc7\u7a0b&#xff0c;\u5305\u62ec\u6162\u5f00\u59cb(slow start)\u3001\u62e5\u585e\u907f\u514d(congestion avoidance)\u3001\u5feb\u91cd\u4f20(fast retransmit)\u548c\u5feb\u6062\u590d(fast recovery)\u3002<\/p>\n<p style=\"text-align:justify\">1. \u6162\u5f00\u59cb<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u6162\u5f00\u59cb\u7b97\u6cd5\u7684\u601d\u8def\u4e3a&#xff0c;\u5728\u6570\u636e\u5f00\u59cb\u53d1\u9001\u65f6&#xff0c;\u7531\u4e8e\u4e0d\u6e05\u695a\u7f51\u7edc\u7684\u8d1f\u8377\u60c5\u51b5&#xff0c;\u5982\u679c\u6b64\u65f6\u7acb\u5373\u628a\u5927\u91cf\u6570\u636e\u53d1\u9001\u5230\u7f51\u7edc&#xff0c;\u90a3\u4e48\u5c31\u6709\u53ef\u80fd\u5f15\u8d77\u7f51\u7edc\u62e5\u585e\u3002\u6839\u636e\u751f\u6d3b\u4e2d\u7684\u7ecf\u9a8c\u8fdb\u884c\u5f15\u4f38&#xff0c;\u8f83\u597d\u7684\u65b9\u6cd5\u662f\u7531\u5c0f\u5927\u5230\u9010\u6e10\u589e\u5927\u53d1\u9001\u7a97\u53e3&#xff0c;\u4e00\u6b65\u6b65\u63a2\u6d4b\u7f51\u7edc\u94fe\u8def\u7684\u6781\u9650&#xff1b;\u4e5f\u5c31\u662f\u8bf4&#xff0c;\u7531\u5c0f\u5230\u5927\u9010\u6e10\u589e\u5927\u62e5\u585e\u7a97\u53e3\u6570\u503c&#xff08;cwnd&#xff09;&#xff0c;\u4e0b\u9762\u662f\u5176\u7b80\u8981\u5de5\u4f5c\u6d41\u7a0b\u56fe\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"490\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250419163613-6803d0fd16684.png\" width=\"907\" \/><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u7531\u4e0a\u56fe\u53ef\u89c1&#xff0c;\u4e00\u5f00\u59cb\u53d1\u9001\u65b9\u7684\u521d\u59cbcwnd \u4e3a1&#xff0c;\u53d1\u9001\u65b9\u53d1\u9001\u7b2c\u4e00\u4e2a\u62a5\u6587\u6bb5M1&#xff0c;\u5e76\u6536\u5230\u63a5\u6536\u65b9\u7684\u786e\u8ba4\u3002\u6b64\u65f6&#xff0c;\u53d1\u9001\u65b9\u5c06cwnd\u4ece1\u589e\u5927\u52302&#xff0c;\u63a5\u7740\u53d1\u9001M2\u548cM3\u4e24\u4e2a\u62a5\u6587\u6bb5&#xff0c;\u6536\u5230\u4e24\u4e2a\u62a5\u6587\u7684\u786e\u8ba4\u540e&#xff0c;\u53d1\u9001\u65b9\u7ee7\u7eed\u5c06cwnd\u52a0\u500d&#xff0c;\u589e\u52a0\u52304\u3002\u53ea\u8981\u7f51\u7edc\u4ecd\u7136\u901a\u7545&#xff0c;\u90a3\u4e48\u53d1\u9001\u65b9\u5c31\u4f1a\u4ee5\u6b64\u7c7b\u63a8&#xff0c;\u5728\u6bcf\u4e00\u8f6e\u7684\u4f20\u8f93\u6210\u529f\u540e\u5c06cwnd\u8fdb\u884c\u52a0\u500d\u7684\u64cd\u4f5c\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u663e\u7136&#xff0c;cwnd\u4e0d\u80fd\u65e0\u9650\u5236\u5730\u52a0\u500d&#xff0c;\u8fd9\u6837\u4f1a\u5f15\u8d77\u7f51\u7edc\u62e5\u585e&#xff0c;\u56e0\u6b64\u9700\u8981\u8bbe\u7f6e\u4e00\u4e2a\u6162\u5f00\u59cb\u95e8\u9650&#xff08;ssthresh&#xff09;\u72b6\u6001\u53d8\u91cf\u3002\u5f53cwnd &#xff1c; ssthresh\u65f6&#xff0c;\u624d\u4f1a\u4f7f\u7528\u4e0a\u8ff0\u7684\u6162\u5f00\u59cb\u7b97\u6cd5\u3002<\/p>\n<p style=\"text-align:justify\">2. \u62e5\u585e\u907f\u514d<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u5f53cwnd\u00a0&#xff1e;\u00a0ssthresh\u65f6&#xff0c;\u7cfb\u7edf\u4f1a\u4f7f\u7528\u62e5\u585e\u907f\u514d\u7b97\u6cd5&#xff0c;\u8be5\u7b97\u6cd5\u7684\u601d\u8def\u662f\u8ba9\u62e5\u585e\u7a97\u53e3&#xff08;cwnd&#xff09;\u7f13\u6162\u5730\u589e\u957f&#xff0c;\u5373\u6bcf\u5b8c\u6210\u4e00\u8f6e\u4f20\u8f93\u5c31\u628a\u53d1\u9001\u65b9\u7684\u62e5\u585e\u7a97\u53e3&#xff08;cwnd&#xff09;\u52a01&#xff0c;\u800c\u4e0d\u662f\u50cf\u6162\u5f00\u59cb\u9636\u6bb5\u90a3\u6837\u52a0\u500d\u589e\u957f\u3002\u56e0\u6b64\u5728\u62e5\u585e\u907f\u514d\u9636\u6bb5\u5c31\u6709\u201c\u52a0\u6cd5\u589e\u5927\u201d(Additive Increase)\u7684\u7279\u70b9\u3002\u8fd9\u8868\u660e\u5728\u62e5\u585e\u907f\u514d\u9636\u6bb5&#xff0c;\u62e5\u585e\u7a97\u53e3&#xff08;cwnd&#xff09;\u6309\u7ebf\u6027\u89c4\u5f8b\u7f13\u6162\u589e\u957f&#xff0c;\u6bd4\u6162\u5f00\u59cb\u7b97\u6cd5\u7684\u62e5\u585e\u7a97\u53e3\u589e\u957f\u901f\u7387\u7f13\u6162\u5f97\u591a\u3002\u4e0b\u56fe\u5c55\u793a\u4e86\u62e5\u585e\u63a7\u5236\u7684\u5de5\u4f5c\u6d41\u7a0b\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"315\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250419163613-6803d0fd59dd1.png\" width=\"907\" \/><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u5728\u4e0a\u56fe\u4e2d&#xff0c;\u6162\u5f00\u59cb\u95e8\u9650\u7684\u521d\u59cb\u503c\u4e3a16\u3002\u4e00\u5f00\u59cb\u7cfb\u7edf\u6267\u884c\u6162\u5f00\u59cb\u7b97\u6cd5&#xff0c;\u53d1\u9001\u65b9\u6bcf\u6210\u529f\u53d1\u9001\u4e00\u8f6e\u62a5\u6587\u6bb5&#xff0c;\u5c31\u628a\u62e5\u585e\u7a97\u53e3\u503c\u52a0\u500d&#xff0c;\u7136\u540e\u5f00\u59cb\u4e0b\u4e00\u8f6e\u7684\u4f20\u8f93\u3002\u56e0\u6b64\u62e5\u585e\u7a97\u53e3cwnd\u968f\u7740\u4f20\u8f93\u8f6e\u6b21\u6309\u6307\u6570\u89c4\u5f8b\u589e\u957f\u3002\u5f53\u62e5\u585e\u7a97\u53e3cwnd\u589e\u957f\u5230\u6162\u5f00\u59cb\u95e8\u9650\u503cssthresh\u00a0\u65f6&#xff0c;\u5c31\u5f00\u59cb\u6539\u4e3a\u6267\u884c\u62e5\u585e\u907f\u514d\u7b97\u6cd5&#xff0c;\u62e5\u585e\u7a97\u53e3\u6309\u7ebf\u6027\u89c4\u5f8b\u589e\u957f\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u5f53\u8fdb\u884c\u5230\u7b2c12\u8f6e\u4f20\u8f93\u65f6&#xff08;\u4e0a\u56fe\u8282\u70b92&#xff09;&#xff0c;\u7f51\u7edc\u51fa\u73b0\u4e86\u8d85\u65f6&#xff0c;\u53d1\u9001\u65b9\u5224\u65ad\u4e3a\u7f51\u7edc\u62e5\u585e\u3002\u4e8e\u662f\u8c03\u6574\u95e8\u9650\u503cssthresh &#061; cwnd \/ 2 &#061; 12&#xff0c;\u540c\u65f6\u8bbe\u7f6e\u62e5\u585e\u7a97\u53e3cwnd &#061;\u00a01&#xff0c;\u91cd\u65b0\u8fdb\u5165\u6162\u5f00\u59cb\u9636\u6bb5\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u4e0a\u56fe\u8282\u70b93\u5c55\u793a\u4e86\u4e00\u4e2a\u7279\u6b8a\u60c5\u51b5&#xff0c;\u6b64\u65f6\u62e5\u585e\u7a97\u53e3cwnd &#061; 16&#xff0c;\u8fd9\u65f6\u51fa\u73b0\u4e86\u53d1\u9001\u65b9\u4e00\u8fde\u6536\u52303\u4e2a\u5bf9\u540c\u4e00\u62a5\u6587\u6bb5\u7684\u91cd\u590d\u786e\u8ba4\u7684\u60c5\u51b5&#xff0c;\u6b64\u65f6\u6267\u884c\u4e86\u62e5\u585e\u907f\u514d\u7b97\u6cd5&#xff0c;\u8c03\u6574\u95e8\u9650\u503cssthresh\u00a0&#061; cwnd \/ 2 &#061; 8\u3002\u8fd9\u662f\u56e0\u4e3a\u5982\u679c\u53d1\u9001\u65b9\u8fdf\u8fdf\u6536\u4e0d\u5230\u786e\u8ba4&#xff0c;\u5c31\u4f1a\u4ea7\u751f\u8d85\u65f6&#xff0c;\u4f1a\u8bef\u8ba4\u4e3a\u7f51\u7edc\u53d1\u751f\u4e86\u62e5\u585e\u3002\u8fd9\u5c31\u5bfc\u81f4\u53d1\u9001\u65b9\u9519\u8bef\u5730\u542f\u52a8\u6162\u5f00\u59cb&#xff0c;\u628a\u62e5\u585e\u7a97\u53e3cwnd\u53c8\u7f6e\u4e3a1&#xff0c;\u56e0\u800c\u964d\u4f4e\u4e86\u4f20\u8f93\u6548\u7387\u3002<\/p>\n<p style=\"text-align:justify\">3. \u5feb\u91cd\u4f20<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0TCP\u4f5c\u4e3a\u4e00\u4e2a\u53ef\u9760\u7684\u534f\u8bae\u9762\u4e34\u7684\u5f88\u5927\u7684\u95ee\u9898\u5c31\u662f\u4e22\u5305&#xff0c;\u4e22\u5305\u5c31\u8981\u91cd\u4f20\u56e0\u6b64\u53d1\u9001\u65b9\u9700\u8981\u6839\u636e\u63a5\u6536\u65b9\u56de\u590d\u7684ACK\u6765\u786e\u8ba4\u662f\u5426\u4e22\u5305\u4e86&#xff0c;\u4e0b\u56fe\u4e3a\u8d85\u65f6\u91cd\u4f20\u7684\u5178\u578b\u65f6\u5e8f\u56fe\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"537\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250419163613-6803d0fd8d142.png\" width=\"584\" \/><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u91cd\u4f20\u8d85\u65f6\u65f6\u95f4&#xff08;RTO&#xff09;\u662f\u968f\u7740\u590d\u6742\u7f51\u7edc\u73af\u5883\u800c\u52a8\u6001\u53d8\u5316\u7684&#xff0c;\u5728\u62e5\u585e\u63a7\u5236\u4e2d\u53d1\u751f\u8d85\u65f6\u91cd\u4f20\u5c06\u4f1a\u6781\u5927\u62c9\u4f4ecwnd&#xff0c;\u5982\u679c\u7f51\u7edc\u72b6\u51b5\u5e76\u6ca1\u6709\u90a3\u4e48\u591a\u7cdf\u7cd5&#xff0c;\u5076\u5c14\u51fa\u73b0\u7f51\u7edc\u6296\u52a8\u9020\u6210\u4e22\u5305\u6216\u8005\u963b\u585e\u4e5f\u975e\u5e38\u5e38\u89c1&#xff0c;\u56e0\u6b64\u89e6\u53d1\u7684\u6162\u542f\u52a8\u5c06\u964d\u4f4e\u901a\u4fe1\u6027\u80fd&#xff0c;\u6545\u51fa\u73b0\u4e86\u5feb\u901f\u91cd\u4f20\u673a\u5236\u3002\u6240\u8c13\u5feb\u901f\u91cd\u4f20\u65f6\u76f8\u6bd4\u8d85\u65f6\u91cd\u4f20\u800c\u8a00\u7684&#xff0c;\u91cd\u53d1\u7b49\u5f85\u65f6\u95f4\u4f1a\u964d\u4f4e\u5e76\u4e14\u540e\u7eed\u5c3d\u91cf\u907f\u514d\u6162\u542f\u52a8&#xff0c;\u6765\u4fdd\u8bc1\u6027\u80fd\u635f\u5931\u5728\u6700\u5c0f\u7684\u7a0b\u5ea6&#xff0c;\u4e0b\u56fe\u4e3a\u5176\u65f6\u5e8f\u56fe\u3002<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"546\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250419163613-6803d0fdbd609.png\" width=\"634\" \/><\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u5feb\u901f\u91cd\u4f20\u548c\u8d85\u65f6\u91cd\u4f20\u7684\u533a\u522b\u5728\u4e8ecwnd\u5728\u53d1\u751f\u62e5\u585e\u65f6\u7684\u53d6\u503c&#xff0c;\u8d85\u65f6\u91cd\u4f20\u4f1a\u5c06cwnd\u4fee\u6539\u4e3a\u6700\u521d\u7684\u503c&#xff0c;\u4e5f\u5c31\u662f\u6162\u542f\u52a8\u7684\u503c&#xff0c;\u5feb\u901f\u91cd\u4f20\u5c06cwnd\u51cf\u534a&#xff0c;\u4e8c\u8005\u90fd\u5c06ssthresh\u8bbe\u7f6e\u4e3acwnd\u7684\u4e00\u534a\u3002\u4ece\u4e8c\u8005\u7684\u533a\u522b\u53ef\u4ee5\u770b\u5230&#xff0c;\u5feb\u901f\u91cd\u4f20\u66f4\u52a0\u4e3b\u52a8&#xff0c;\u6709\u5229\u4e8e\u4fdd\u8bc1\u94fe\u8def\u7684\u4f20\u8f93\u6027\u80fd\u3002<\/p>\n<p style=\"text-align:justify\">4. \u5feb\u6062\u590d<\/p>\n<p style=\"margin-left:.0001pt;margin-right:0;text-align:justify\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u5728\u5feb\u901f\u91cd\u4f20\u4e4b\u540e\u5c31\u4f1a\u8fdb\u5165\u5feb\u901f\u6062\u590d\u9636\u6bb5&#xff0c;\u6b64\u65f6\u7684cwnd\u4e3a\u4e0a\u6b21\u53d1\u751f\u62e5\u585e\u65f6\u7684cwnd\u76841\/2&#xff0c;\u4e4b\u540ecwnd\u518d\u7ebf\u6027\u589e\u52a0\u91cd\u590d\u4e4b\u524d\u7684\u8fc7\u7a0b\u3002<\/p>\n<h2>2. lwIP<\/h2>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 ESP-IDF\u4f7f\u7528lwIP\u5e93\u5b9e\u73b0TCP\/IP\u534f\u8bae\u6808&#xff0c;\u8fd9\u4e2a\u5e93\u5728\u5927\u591a\u6570\u5d4c\u5165\u5f0f\u7cfb\u7edf\u4e2d\u90fd\u6709\u7528\u5230&#xff0c;\u5b83\u662f\u5bf9\u5e95\u5c42\u786c\u4ef6\u7684\u4e0a\u5c42\u5c01\u88c5&#xff0c;\u6240\u4ee5\u5982\u679c\u672a\u6765\u8981\u5199\u6bd4\u5982Linux\u7684TCP\/IP\u5e94\u7528&#xff0c;\u4ee3\u7801\u4e5f\u662f\u901a\u7528\u7684\u3002<\/p>\n<h2>3. \u4f8b\u7a0b<\/h2>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u4f8b\u7a0b\u5206\u522b\u5728ESP32\u4e0a\u5b9e\u73b0TCP\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u7aef&#xff0c;\u4f7f\u7528\u7535\u8111\u4f5c\u4e3a\u53e6\u4e00\u65b9\u8fdb\u884c\u7b80\u5355\u901a\u4fe1\u6d4b\u8bd5\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f&#xff0c;\u6d4b\u8bd5\u65f6&#xff0c;<span style=\"background-color:#ffd900\">ESP32\u548c\u7535\u8111\u5fc5\u987b\u5904\u4e8e\u540c\u4e00\u5c40\u57df\u7f51<\/span>\u3002<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u7535\u8111\u7aef\u6d4b\u8bd5\u4f1a\u4f7f\u7528\u7684\u4e0a\u4f4d\u673a\u4e3a\u91ce\u706b\u4e32\u53e3\u8c03\u8bd5\u52a9\u624b&#xff0c;\u4e0b\u8f7d\u5730\u5740&#xff1a;FireTools<\/p>\n<h3>3.1 \u5ba2\u6237\u7aef<\/h3>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u8fd9\u4e2a\u4f8b\u7a0b\u914d\u7f6eESP32\u4e3a\u5ba2\u6237\u7aef&#xff0c;\u5f53\u8fde\u63a5WiFi\u70ed\u70b9\u6210\u529f\u540e\u4f1a\u8bf7\u6c42\u8fde\u63a5\u670d\u52a1\u7aef&#xff0c;\u8fde\u63a5\u6210\u529f\u540e\u4f1a\u53d1\u9001\u4e00\u6bb5\u6d88\u606f&#xff0c;\u7136\u540e\u963b\u585e\u7b49\u5f85\u670d\u52a1\u7aef\u56de\u590d&#xff0c;\u670d\u52a1\u7aef\u6062\u590d\u6d88\u606f\u540eESP32\u4f1a\u4e3b\u52a8\u5173\u95ed\u5957\u63a5\u5b57\u3002<\/p>\n<p>#include &#034;freertos\/FreeRTOS.h&#034;<br \/>\n#include &#034;freertos\/queue.h&#034;<br \/>\n#include &#034;freertos\/semphr.h&#034;<br \/>\n#include &#034;esp_system.h&#034;<br \/>\n#include &#034;esp_wifi.h&#034;<br \/>\n#include &#034;esp_event.h&#034;<br \/>\n#include &#034;esp_log.h&#034;<br \/>\n#include &#034;esp_mac.h&#034;<br \/>\n#include &#034;nvs_flash.h&#034;<br \/>\n#include &#034;sys\/socket.h&#034;<br \/>\n#include &#034;lwip\/err.h&#034;<br \/>\n#include &#034;lwip\/sys.h&#034;<br \/>\n#include &#034;netdb.h&#034;<br \/>\n#include &#034;arpa\/inet.h&#034;<\/p>\n<p>#include &lt;string.h&gt;<\/p>\n<p>#define TAG &#034;app&#034;<br \/>\n#define HOST_IP_ADDR &#034;192.168.10.117&#034;<br \/>\n#define HOST_PORT 20001<\/p>\n<p>static char rx_buffer[128];<br \/>\nstatic const char *payload &#061; &#034;Message from ESP32&#034;;<br \/>\nstatic TaskHandle_t client_task_handle;<\/p>\n<p>static void tcp_client_task(void *args)<br \/>\n{<br \/>\n    struct sockaddr_in dest_addr;<br \/>\n    inet_pton(AF_INET, HOST_IP_ADDR, &amp;dest_addr.sin_addr);<br \/>\n    dest_addr.sin_family &#061; AF_INET;<br \/>\n    dest_addr.sin_port &#061; htons(HOST_PORT);<\/p>\n<p>    while (1) {<br \/>\n        int sock &#061;  socket(AF_INET, SOCK_STREAM, IPPROTO_IP);<br \/>\n        if (sock &lt; 0) {<br \/>\n            ESP_LOGE(TAG, &#034;Unable to create socket: errno %d&#034;, errno);<br \/>\n            break;<br \/>\n        }<br \/>\n        ESP_LOGI(TAG, &#034;Socket created, connecting to %s:%d&#034;, HOST_IP_ADDR, HOST_PORT);<\/p>\n<p>        int err &#061; connect(sock, (struct sockaddr *)&amp;dest_addr, sizeof(dest_addr));<br \/>\n        if (err !&#061; 0) {<br \/>\n            ESP_LOGE(TAG, &#034;Socket unable to connect: errno %d&#034;, errno);<br \/>\n            break;<br \/>\n        }<br \/>\n        ESP_LOGI(TAG, &#034;Successfully connected&#034;);<\/p>\n<p>        err &#061; send(sock, payload, strlen(payload), 0);<br \/>\n        if (err &lt; 0) {<br \/>\n            ESP_LOGE(TAG, &#034;Error occurred during sending: errno %d&#034;, errno);<br \/>\n            break;<br \/>\n        }<\/p>\n<p>        memset(rx_buffer, 0, sizeof(rx_buffer));<br \/>\n        int len &#061; recv(sock, rx_buffer, sizeof(rx_buffer) &#8211; 1, 0);<br \/>\n        if (len &lt; 0) {<br \/>\n            ESP_LOGE(TAG, &#034;recv failed: errno %d&#034;, errno);<br \/>\n        } else {<br \/>\n            ESP_LOGI(TAG, &#034;Received %d bytes from %s:&#034;, len, HOST_IP_ADDR);<br \/>\n            ESP_LOGI(TAG, &#034;data: %s&#034;, rx_buffer);<br \/>\n        }<\/p>\n<p>        close(sock);<\/p>\n<p>        vTaskDelay(1000 \/ portTICK_PERIOD_MS);<br \/>\n    }<br \/>\n}<\/p>\n<p>static void wifi_event_handler(void* arg,<br \/>\n                               esp_event_base_t event_base,<br \/>\n                               int32_t event_id,<br \/>\n                               void* event_data)<br \/>\n{<br \/>\n    if (event_base &#061;&#061; IP_EVENT) {<br \/>\n        if (event_id &#061;&#061; IP_EVENT_STA_GOT_IP) {<br \/>\n            xTaskCreate(tcp_client_task, &#034;tcp_client&#034;, 2048, NULL, 5, &amp;client_task_handle);<br \/>\n        }<br \/>\n    } else if (event_base &#061;&#061; WIFI_EVENT) {<br \/>\n        if (event_id &#061;&#061; WIFI_EVENT_STA_DISCONNECTED) {<br \/>\n            vTaskDelete(client_task_handle);<br \/>\n        } else if (event_id &#061;&#061; WIFI_EVENT_STA_START) {<br \/>\n            esp_wifi_connect();<br \/>\n        }<br \/>\n    }<br \/>\n}<\/p>\n<p>int app_main()<br \/>\n{<br \/>\n    \/* \u521d\u59cb\u5316NVS *\/<br \/>\n    esp_err_t ret &#061; nvs_flash_init();<br \/>\n    if (ret &#061;&#061; ESP_ERR_NVS_NO_FREE_PAGES || ret &#061;&#061; ESP_ERR_NVS_NEW_VERSION_FOUND) {<br \/>\n        ESP_ERROR_CHECK(nvs_flash_erase());<br \/>\n        ESP_ERROR_CHECK(nvs_flash_init());<br \/>\n    }<\/p>\n<p>    \/* \u521d\u59cb\u5316WiFi\u534f\u8bae\u6808 *\/<br \/>\n    ESP_ERROR_CHECK(esp_netif_init());<br \/>\n    ESP_ERROR_CHECK(esp_event_loop_create_default());<br \/>\n    esp_netif_create_default_wifi_sta();<\/p>\n<p>    wifi_init_config_t cfg &#061; WIFI_INIT_CONFIG_DEFAULT();<br \/>\n    ESP_ERROR_CHECK(esp_wifi_init(&amp;cfg));<\/p>\n<p>    ESP_ERROR_CHECK(esp_event_handler_instance_register(WIFI_EVENT,<br \/>\n                                                        ESP_EVENT_ANY_ID,<br \/>\n                                                        &amp;wifi_event_handler,<br \/>\n                                                        NULL,<br \/>\n                                                        NULL));<\/p>\n<p>    ESP_ERROR_CHECK(esp_event_handler_instance_register(IP_EVENT,<br \/>\n                                                        ESP_EVENT_ANY_ID,<br \/>\n                                                        &amp;wifi_event_handler,<br \/>\n                                                        NULL,<br \/>\n                                                        NULL));<\/p>\n<p>    wifi_config_t wifi_config &#061; {<br \/>\n        .sta &#061; {<br \/>\n            .ssid &#061; &#034;Your SSID&#034;,<br \/>\n            .password &#061; &#034;Your password&#034;,<br \/>\n            .threshold.authmode &#061; WIFI_AUTH_WPA_WPA2_PSK,<br \/>\n        },<br \/>\n    };<\/p>\n<p>    ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA));<br \/>\n    ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &amp;wifi_config));<br \/>\n    ESP_ERROR_CHECK(esp_wifi_start());<\/p>\n<p>    return 0;<br \/>\n}<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 ESP32\u7684WiFi\u9a71\u52a8\u521d\u59cb\u5316\u5728\u524d\u9762\u7684\u6587\u7ae0\u5df2\u7ecf\u6709\u8be6\u7ec6\u7684\u4ecb\u7ecd\u4e86&#xff0c;\u8fd9\u91cc\u4e0d\u518d\u8d58\u8ff0\u3002<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u5728\u56de\u8c03\u51fd\u6570\u4e2d&#xff0c;\u5f53\u9a71\u52a8\u83b7\u53d6\u5230IP\u540e&#xff0c;\u5c31\u4f1a\u521b\u5efaTCP\u5ba2\u6237\u7aef\u7684\u4efb\u52a1\u3002<\/p>\n<p>1. \u521b\u5efasocket\u5957\u63a5\u5b57<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u8c03\u7528socket\u51fd\u6570\u521b\u5efa&#xff0c;\u7b2c\u4e00\u4e2a\u53c2\u6570\u8868\u793a\u57df&#xff0c;\u8fd9\u91cc\u4f7f\u7528IPv4&#xff0c;\u5bf9\u5e94IP_INET&#xff1b;\u7b2c\u4e8c\u4e2a\u53c2\u6570\u8868\u793asocket\u7c7b\u578b&#xff0c;TCP\u534f\u8bae\u53ea\u80fd\u586bSOCK_STREAM&#xff1b;\u7b2c\u4e09\u4e2a\u53c2\u6570\u8868\u793a\u534f\u8bae\u6808\u7c7b\u578b&#xff0c;\u8fd9\u91cc\u586bIPPROTO_IP\u3002\u51fd\u6570\u4f1a\u8fd4\u56de\u5957\u63a5\u5b57\u63cf\u8ff0\u7b26\u3002<\/p>\n<p>2. \u8fde\u63a5\u670d\u52a1\u5668<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u8c03\u7528connect\u51fd\u6570&#xff0c;\u7b2c\u4e00\u4e2a\u53c2\u6570\u4f20\u5165\u5957\u63a5\u5b57\u63cf\u8ff0\u7b26&#xff1b;\u6bd4\u8f83\u91cd\u8981\u7684\u662f\u7b2c\u4e8c\u4e2a\u53c2\u6570&#xff0c;\u8981\u4f20\u5165\u670d\u52a1\u5668\u7684\u5730\u5740\u4fe1\u606f\u3002\u7ed3\u6784\u4f53\u7684\u5b9a\u4e49\u5982\u4e0b&#xff1a;<\/p>\n<p>struct sockaddr_in {<br \/>\n  u8_t            sin_len;<br \/>\n  sa_family_t     sin_family;<br \/>\n  in_port_t       sin_port;<br \/>\n  struct in_addr  sin_addr;<br \/>\n#define SIN_ZERO_LEN 8<br \/>\n  char            sin_zero[SIN_ZERO_LEN];<br \/>\n};<\/p>\n<ul>\n<li>sin_len&#xff1a;\u6570\u636e\u957f\u5ea6&#xff08;\u4e00\u822c\u4e0d\u9700\u8981\u586b&#xff09;&#xff1b;<\/li>\n<li>sin_family&#xff1a;\u5957\u63a5\u5b57\u7c7b\u578b&#xff0c;IPv4\u586bAF_INET&#xff0c;IPv6\u586bAF_INET6&#xff0c;\u5176\u4ed6\u586bAF_UNSPEC&#xff1b;<\/li>\n<li>sin_port&#xff1a;\u7aef\u53e3&#xff1b;<\/li>\n<li>sin_zero&#xff1a;\u4e0a\u5c42\u9884\u7559\u5b57\u8282&#xff08;\u4e0d\u7528\u7ba1&#xff09;\u3002<\/li>\n<\/ul>\n<p>3.\u00a0 \u53d1\u9001\u6570\u636e<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u8c03\u7528send\u51fd\u6570\u3002\u4f20\u5165\u5957\u63a5\u5b57\u63cf\u8ff0\u7b26\u3001\u6570\u636e\u6307\u9488\u548c\u6570\u636e\u957f\u5ea6\u5373\u53ef&#xff1b;\u6700\u540e\u4e00\u4e2a\u53c2\u6570\u662f\u6807\u5fd7\u4f4d&#xff0c;\u4e00\u822c\u586b0\u5373\u53ef&#xff0c;\u53ef\u9009\u7684\u6807\u5fd7\u4f4d\u5982\u4e0b&#xff1a;<\/p>\n<p>#define MSG_PEEK       0x01<br \/>\n#define MSG_WAITALL    0x02<br \/>\n#define MSG_OOB        0x04<br \/>\n#define MSG_DONTWAIT   0x08<br \/>\n#define MSG_MORE       0x10<br \/>\n#define MSG_NOSIGNAL   0x20 <\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u8fd9\u4e9b\u6807\u5fd7\u4f4d\u662f\u53d1\u9001\u548c\u63a5\u6536\u90fd\u652f\u6301\u7684&#xff0c;\u6bd4\u8f83\u5e38\u7528\u7684\u662fMSG_DONTWAIT&#xff0c;\u50cf\u53d1\u9001\u548c\u63a5\u6536\u51fd\u6570\u662f\u963b\u585e\u7684&#xff0c;\u4f7f\u80fd\u8fd9\u4e2a\u6807\u5fd7\u4f4d\u53ef\u4ee5\u8ba9\u51fd\u6570\u7acb\u5373\u8fd4\u56de&#xff0c;\u4e0d\u7b49\u5f85\u6570\u636e\u3002<\/p>\n<p>4. \u63a5\u6536\u6570\u636e<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u8c03\u7528recv\u51fd\u6570\u3002\u4f20\u5165\u7684\u53c2\u6570\u4e0esend\u51fd\u6570\u662f\u4e00\u81f4\u7684&#xff0c;\u4e0d\u518d\u8d58\u8ff0\u3002<\/p>\n<p>5. \u5173\u95ed\u8fde\u63a5<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u8c03\u7528close\u51fd\u6570\u3002\u4f20\u5165\u5957\u63a5\u5b57\u63cf\u8ff0\u7b26\u5373\u53ef\u3002<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u6d4b\u8bd5\u7684\u65f6\u5019\u5148\u6253\u5f00\u4e0a\u4f4d\u673a&#xff0c;\u8bbe\u7f6e\u4e3aTCP\u670d\u52a1\u5668&#xff0c;\u586b\u5199\u7535\u8111\u7684IP\u548c\u7aef\u53e3&#xff0c;\u7aef\u53e3\u662f\u81ea\u5b9a\u4e49\u7684&#xff0c;\u4f46<span style=\"background-color:#ffd900\">\u6ce8\u610f\u4e0d\u8981\u4e0e\u539f\u6709\u7684\u7aef\u53e3\u51b2\u7a81<\/span>&#xff0c;\u5efa\u8bae\u8bbe\u7f6e20000\u4ee5\u4e0a\u6bd4\u8f83\u4fdd\u9669&#xff1b;\u6700\u540e\u70b9\u51fb\u5f00\u59cb\u76d1\u542c\u3002<\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1368\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250419163613-6803d0fdf09c3.png\" width=\"2160\" \/><\/p>\n<p style=\"text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"729\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250419163615-6803d0ff5a52b.png\" width=\"1122\" \/><\/p>\n<h3>3.2 \u670d\u52a1\u7aef<\/h3>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u8fd9\u4e2a\u4f8b\u7a0b\u5c31\u662f\u5728ESP32\u4e0a\u642d\u5efa\u4e00\u4e2aTCP\u670d\u52a1\u5668&#xff0c;\u63a5\u53d7\u5c40\u57df\u7f51\u4e2d\u7684\u5ba2\u6237\u7aef\u8fde\u63a5\u5e76\u63a5\u6536\u6570\u636e\u3002<\/p>\n<p>#include &#034;freertos\/FreeRTOS.h&#034;<br \/>\n#include &#034;freertos\/queue.h&#034;<br \/>\n#include &#034;freertos\/semphr.h&#034;<br \/>\n#include &#034;esp_system.h&#034;<br \/>\n#include &#034;esp_wifi.h&#034;<br \/>\n#include &#034;esp_event.h&#034;<br \/>\n#include &#034;esp_log.h&#034;<br \/>\n#include &#034;esp_mac.h&#034;<br \/>\n#include &#034;nvs_flash.h&#034;<br \/>\n#include &#034;sys\/socket.h&#034;<br \/>\n#include &#034;lwip\/err.h&#034;<br \/>\n#include &#034;lwip\/sys.h&#034;<br \/>\n#include &#034;netdb.h&#034;<br \/>\n#include &#034;arpa\/inet.h&#034;<\/p>\n<p>#include &lt;string.h&gt;<\/p>\n<p>#define TAG &#034;app&#034;<br \/>\n#define HOST_PORT 20001<\/p>\n<p>static const char *payload &#061; &#034;I have received your message&#034;;<br \/>\nstatic TaskHandle_t server_task_handle;<\/p>\n<p>static void tcp_client_task(void *args)<br \/>\n{<br \/>\n    int *sock &#061; args;<br \/>\n    int len;<br \/>\n    char rx_buffer[128] &#061; {0};<\/p>\n<p>    while (1) {<br \/>\n        memset(rx_buffer, 0, sizeof(rx_buffer));<br \/>\n        len &#061; recv(*sock, rx_buffer, sizeof(rx_buffer) &#8211; 1, 0);<br \/>\n        if (len &lt; 0) {<br \/>\n            ESP_LOGE(TAG, &#034;Error occurred during receiving: errno %d&#034;, errno);<br \/>\n        } else if (len &#061;&#061; 0) {<br \/>\n            ESP_LOGW(TAG, &#034;Connection closed&#034;);<br \/>\n            goto __exit;<br \/>\n        } else {<br \/>\n            ESP_LOGI(TAG, &#034;Received %d bytes, data: %s&#034;, len, rx_buffer);<br \/>\n            send(*sock, payload, strlen(payload), 0);<br \/>\n        }<br \/>\n    }<\/p>\n<p>__exit:<br \/>\n    close(*sock);<br \/>\n    free(sock);<br \/>\n    vTaskDelete(NULL);<br \/>\n}<\/p>\n<p>static void tcp_server_task(void *args)<br \/>\n{<br \/>\n    esp_ip4_addr_t *ip_addr &#061; args;<\/p>\n<p>    struct sockaddr_in dest_addr &#061; {0};<br \/>\n    dest_addr.sin_addr.s_addr &#061; ip_addr-&gt;addr;<br \/>\n    dest_addr.sin_family &#061; AF_INET;<br \/>\n    dest_addr.sin_port &#061; htons(HOST_PORT);<\/p>\n<p>    int sock &#061; socket(AF_INET, SOCK_STREAM, IPPROTO_IP);<br \/>\n    if (sock &lt; 0) {<br \/>\n        ESP_LOGE(TAG, &#034;Unable to create socket: errno %d&#034;, errno);<br \/>\n        goto __exit;<br \/>\n    }<\/p>\n<p>    int err &#061; bind(sock, (struct sockaddr *)&amp;dest_addr, sizeof(dest_addr));<br \/>\n    if (err !&#061; 0) {<br \/>\n        ESP_LOGE(TAG, &#034;Socket unable to bind: errno %d&#034;, errno);<br \/>\n        goto __exit;<br \/>\n    }<\/p>\n<p>    err &#061; listen(sock, 1);<br \/>\n    if (err !&#061; 0) {<br \/>\n        ESP_LOGE(TAG, &#034;Error occurred during listen: errno %d&#034;, errno);<br \/>\n        goto __exit;<br \/>\n    }<\/p>\n<p>    ESP_LOGI(TAG, &#034;Server listen at &#034; IPSTR &#034;:%d&#034;, IP2STR(ip_addr), HOST_PORT);<\/p>\n<p>    while (1) {<br \/>\n        struct sockaddr_in source_addr &#061; {0};<br \/>\n        socklen_t addr_len &#061; sizeof(struct sockaddr_in);<br \/>\n        int *client &#061; malloc(sizeof(int));<br \/>\n        *client &#061; accept(sock, (struct sockaddr *)&amp;source_addr, &amp;addr_len);<br \/>\n        if (*client &lt; 0) {<br \/>\n            ESP_LOGE(TAG, &#034;Unable to accept connection: errno %d&#034;, errno);<br \/>\n        } else {<br \/>\n            ESP_LOGI(TAG, &#034;Client &#034; IPSTR &#034;:%d connected&#034;, IP2STR((struct esp_ip4_addr *)&amp;source_addr.sin_addr), source_addr.sin_port);<br \/>\n            xTaskCreate(tcp_client_task, &#034;client_task&#034;, 2048, client, 6, NULL);<br \/>\n        }<br \/>\n    }<\/p>\n<p>__exit:<br \/>\n    close(sock);<br \/>\n    free(ip_addr);<br \/>\n    vTaskDelete(NULL);<br \/>\n}<\/p>\n<p>static void wifi_event_handler(void* arg,<br \/>\n                               esp_event_base_t event_base,<br \/>\n                               int32_t event_id,<br \/>\n                               void* event_data)<br \/>\n{<br \/>\n    if (event_base &#061;&#061; IP_EVENT) {<br \/>\n        if (event_id &#061;&#061; IP_EVENT_STA_GOT_IP) {<br \/>\n            ip_event_got_ip_t *data &#061; event_data;<br \/>\n            esp_ip4_addr_t *ip_addr &#061; malloc(sizeof(esp_ip4_addr_t));<br \/>\n            memcpy(ip_addr, &amp;data-&gt;ip_info.ip, sizeof(esp_ip4_addr_t));<br \/>\n            xTaskCreate(tcp_server_task, &#034;tcp_server&#034;, 2048, ip_addr, 5, &amp;server_task_handle);<br \/>\n        }<br \/>\n    } else if (event_base &#061;&#061; WIFI_EVENT) {<br \/>\n        if (event_id &#061;&#061; WIFI_EVENT_STA_DISCONNECTED) {<br \/>\n            vTaskDelete(server_task_handle);<br \/>\n        } else if (event_id &#061;&#061; WIFI_EVENT_STA_START) {<br \/>\n            esp_wifi_connect();<br \/>\n        }<br \/>\n    }<br \/>\n}<\/p>\n<p>int app_main()<br \/>\n{<br \/>\n    \/* \u521d\u59cb\u5316NVS *\/<br \/>\n    esp_err_t ret &#061; nvs_flash_init();<br \/>\n    if (ret &#061;&#061; ESP_ERR_NVS_NO_FREE_PAGES || ret &#061;&#061; ESP_ERR_NVS_NEW_VERSION_FOUND) {<br \/>\n        ESP_ERROR_CHECK(nvs_flash_erase());<br \/>\n        ESP_ERROR_CHECK(nvs_flash_init());<br \/>\n    }<\/p>\n<p>    \/* \u521d\u59cb\u5316WiFi\u534f\u8bae\u6808 *\/<br \/>\n    ESP_ERROR_CHECK(esp_netif_init());<br \/>\n    ESP_ERROR_CHECK(esp_event_loop_create_default());<br \/>\n    esp_netif_create_default_wifi_sta();<\/p>\n<p>    wifi_init_config_t cfg &#061; WIFI_INIT_CONFIG_DEFAULT();<br \/>\n    ESP_ERROR_CHECK(esp_wifi_init(&amp;cfg));<\/p>\n<p>    ESP_ERROR_CHECK(esp_event_handler_instance_register(WIFI_EVENT,<br \/>\n                                                        ESP_EVENT_ANY_ID,<br \/>\n                                                        &amp;wifi_event_handler,<br \/>\n                                                        NULL,<br \/>\n                                                        NULL));<\/p>\n<p>    ESP_ERROR_CHECK(esp_event_handler_instance_register(IP_EVENT,<br \/>\n                                                        ESP_EVENT_ANY_ID,<br \/>\n                                                        &amp;wifi_event_handler,<br \/>\n                                                        NULL,<br \/>\n                                                        NULL));<\/p>\n<p>    wifi_config_t wifi_config &#061; {<br \/>\n        .sta &#061; {<br \/>\n            .ssid &#061; &#034;Your SSID&#034;,<br \/>\n            .password &#061; &#034;Your password&#034;,<br \/>\n            .threshold.authmode &#061; WIFI_AUTH_WPA_WPA2_PSK,<br \/>\n        },<br \/>\n    };<\/p>\n<p>    ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA));<br \/>\n    ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &amp;wifi_config));<br \/>\n    ESP_ERROR_CHECK(esp_wifi_start());<\/p>\n<p>    return 0;<br \/>\n}<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u670d\u52a1\u5668\u7684\u4ee3\u7801\u4e0e\u5ba2\u6237\u7aef\u662f\u6709\u4e00\u90e8\u5206\u91cd\u5408\u7684&#xff0c;\u6240\u4ee5\u4e0b\u9762\u53ea\u91cd\u70b9\u4ecb\u7ecd\u4e0d\u540c\u7684\u5730\u65b9\u3002<\/p>\n<p>1. \u521b\u5efa\u5957\u63a5\u5b57<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u53c2\u8003\u4e0a\u9762\u3002<\/p>\n<p>2. \u7ed1\u5b9aIP\u4e0e\u7aef\u53e3<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u8c03\u7528bind\u51fd\u6570\u3002\u4f20\u5165\u7684\u53c2\u6570\u5176\u5b9e\u8ddfconnect\u51fd\u6570\u662f\u4e00\u6837\u7684&#xff1b;\u4f46\u662f\u8fd9\u91cc\u7684IP\u5730\u5740\u662f\u81ea\u5df1\u7684IP\u5730\u5740&#xff0c;\u7aef\u53e3\u7684\u8bdd\u5c31\u662f\u81ea\u5b9a\u4e49\u7684\u3002<\/p>\n<p>3. \u76d1\u542c\u7aef\u53e3<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u8c03\u7528listen\u51fd\u6570\u3002\u7b2c\u4e00\u4e2a\u53c2\u6570\u4f20\u5165\u5957\u63a5\u5b57\u63cf\u8ff0\u7b26&#xff0c;\u7b2c\u4e8c\u4e2a\u53c2\u6570\u7528\u6765\u4f7f\u80fdlog\u8bb0\u5f55\u3002<\/p>\n<p>4. \u63a5\u53d7\u5ba2\u6237\u7aef\u8fde\u63a5<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u8c03\u7528accept\u51fd\u6570\u3002\u4f20\u5165\u5957\u63a5\u5b57\u63cf\u8ff0\u7b26\u3001IP\u5730\u5740\u7ed3\u6784\u4f53\u548c\u7ed3\u6784\u4f53\u7684\u957f\u5ea6\u3002\u8fd9\u4e2a\u7ed3\u6784\u4f53\u662f\u7528\u6765\u63a5\u6536\u5ba2\u6237\u7aef\u7684IP\u4fe1\u606f\u7684&#xff0c;\u521d\u59cb\u5316\u4e3a\u7a7a\u5373\u53ef\u3002\u8fd9\u4e2a\u51fd\u6570\u662f\u963b\u585e\u7684&#xff0c;\u53ea\u8981\u6ca1\u6709\u5ba2\u6237\u7aef\u8fde\u63a5\u5c31\u4e0d\u4f1a\u8fd4\u56de&#xff1b;\u5982\u679c\u6709\u5ba2\u6237\u7aef\u8fde\u63a5&#xff0c;\u5c31\u4f1a\u8fd4\u56de\u8be5\u5ba2\u6237\u7aef\u7684\u5957\u63a5\u5b57\u63cf\u8ff0\u7b26\u3002<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u4f8b\u7a0b\u4e2d&#xff0c;\u4e00\u65e6\u5ba2\u6237\u7aef\u6210\u529f\u8fde\u63a5\u5c31\u4f1a\u521b\u5efa\u4e00\u4e2a\u7ebf\u7a0b\u5904\u7406\u8fd9\u4e2a\u5ba2\u6237\u7aef\u7684\u6570\u636e&#xff0c;\u8fd9\u6837\u7684\u8bdd\u5c31\u80fd\u5b9e\u73b0\u591a\u5ba2\u6237\u7aef\u7684\u8fde\u63a5\u670d\u52a1\u3002<\/p>\n<p>5. \u63a5\u6536\u6570\u636e<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0\u00a0\u53c2\u8003\u4e0a\u9762\u3002\u5982\u679crecv\u51fd\u6570\u8fd4\u56de0\u5219\u4ee3\u8868\u5ba2\u6237\u7aef\u65ad\u5f00\u4e86\u8fde\u63a5&#xff0c;\u8fd9\u65f6\u6211\u4eec\u5c31\u53ef\u4ee5\u5173\u95ed\u8fd9\u4e2a\u5957\u63a5\u5b57&#xff0c;\u9000\u51fa\u7ebf\u7a0b\u3002<\/p>\n<p>6. \u53d1\u9001\u6570\u636e<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u53c2\u8003\u4e0a\u9762\u3002<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u6d4b\u8bd5\u65f6\u5148\u5c06ESP32\u4e0a\u7535&#xff0c;\u786e\u4fdd\u670d\u52a1\u5668\u5df2\u7ecf\u542f\u52a8\u5e76\u5904\u4e8e\u76d1\u542c\u72b6\u6001&#xff1b;\u7136\u540e\u5728\u4e0a\u4f4d\u673a\u8fd9\u91cc\u8bbe\u7f6e\u4e3aTCP\u5ba2\u6237\u7aef\u6a21\u5f0f&#xff0c;\u586b\u5165ESP32\u7684IP\u548c\u7aef\u53e3&#xff1b;\u7136\u540e\u5c31\u53ef\u4ee5\u8fde\u63a5\u5e76\u53d1\u9001\u6570\u636e\u4e86\u3002<\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1368\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250419163615-6803d0ffc6914.png\" width=\"2160\" \/><\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"319\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250419163617-6803d10134b72.png\" width=\"1116\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.6k\u6b21\uff0c\u70b9\u8d5e28\u6b21\uff0c\u6536\u85cf20\u6b21\u3002TCP\uff08Transmission Control Protocol\uff09\uff0c\u5168\u79f0\u3002\uff0c\u6bcf\u4e00\u4e2aTCP\u8fde\u63a5\u53ea\u80fd\u662f\u70b9\u5bf9\u70b9\u7684\uff08\u4e00\u5bf9\u4e00\uff09\uff1b\u63d0\u4f9b\uff1b\u63d0\u4f9b\uff1b\u3002_esp32 tcp<\/p>\n","protected":false},"author":2,"featured_media":28472,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[174,2289,822,205,270,78],"topic":[],"class_list":["post-28482","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-c","tag-esp32","tag-mcu","tag-tcp-ip","tag-270","tag-78"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u3010ESP32\u3011ESP-IDF\u5f00\u53d1 | WiFi\u5f00\u53d1 | TCP\u4f20\u8f93\u63a7\u5236\u534f\u8bae + TCP\u670d\u52a1\u5668\u548c\u5ba2\u6237\u7aef\u4f8b\u7a0b - \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\/28482.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u3010ESP32\u3011ESP-IDF\u5f00\u53d1 | WiFi\u5f00\u53d1 | TCP\u4f20\u8f93\u63a7\u5236\u534f\u8bae + TCP\u670d\u52a1\u5668\u548c\u5ba2\u6237\u7aef\u4f8b\u7a0b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.6k\u6b21\uff0c\u70b9\u8d5e28\u6b21\uff0c\u6536\u85cf20\u6b21\u3002TCP\uff08Transmission Control Protocol\uff09\uff0c\u5168\u79f0\u3002\uff0c\u6bcf\u4e00\u4e2aTCP\u8fde\u63a5\u53ea\u80fd\u662f\u70b9\u5bf9\u70b9\u7684\uff08\u4e00\u5bf9\u4e00\uff09\uff1b\u63d0\u4f9b\uff1b\u63d0\u4f9b\uff1b\u3002_esp32 tcp\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/28482.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-19T16:36:18+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250419163612-6803d0fcb3bee.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=\"9 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/28482.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/28482.html\",\"name\":\"\u3010ESP32\u3011ESP-IDF\u5f00\u53d1 | WiFi\u5f00\u53d1 | TCP\u4f20\u8f93\u63a7\u5236\u534f\u8bae + TCP\u670d\u52a1\u5668\u548c\u5ba2\u6237\u7aef\u4f8b\u7a0b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-04-19T16:36:18+00:00\",\"dateModified\":\"2025-04-19T16:36:18+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/28482.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/28482.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/28482.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u3010ESP32\u3011ESP-IDF\u5f00\u53d1 | WiFi\u5f00\u53d1 | TCP\u4f20\u8f93\u63a7\u5236\u534f\u8bae + TCP\u670d\u52a1\u5668\u548c\u5ba2\u6237\u7aef\u4f8b\u7a0b\"}]},{\"@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":"\u3010ESP32\u3011ESP-IDF\u5f00\u53d1 | WiFi\u5f00\u53d1 | TCP\u4f20\u8f93\u63a7\u5236\u534f\u8bae + TCP\u670d\u52a1\u5668\u548c\u5ba2\u6237\u7aef\u4f8b\u7a0b - \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\/28482.html","og_locale":"zh_CN","og_type":"article","og_title":"\u3010ESP32\u3011ESP-IDF\u5f00\u53d1 | WiFi\u5f00\u53d1 | TCP\u4f20\u8f93\u63a7\u5236\u534f\u8bae + TCP\u670d\u52a1\u5668\u548c\u5ba2\u6237\u7aef\u4f8b\u7a0b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.6k\u6b21\uff0c\u70b9\u8d5e28\u6b21\uff0c\u6536\u85cf20\u6b21\u3002TCP\uff08Transmission Control Protocol\uff09\uff0c\u5168\u79f0\u3002\uff0c\u6bcf\u4e00\u4e2aTCP\u8fde\u63a5\u53ea\u80fd\u662f\u70b9\u5bf9\u70b9\u7684\uff08\u4e00\u5bf9\u4e00\uff09\uff1b\u63d0\u4f9b\uff1b\u63d0\u4f9b\uff1b\u3002_esp32 tcp","og_url":"https:\/\/www.wsisp.com\/helps\/28482.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-04-19T16:36:18+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250419163612-6803d0fcb3bee.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"9 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/28482.html","url":"https:\/\/www.wsisp.com\/helps\/28482.html","name":"\u3010ESP32\u3011ESP-IDF\u5f00\u53d1 | WiFi\u5f00\u53d1 | TCP\u4f20\u8f93\u63a7\u5236\u534f\u8bae + TCP\u670d\u52a1\u5668\u548c\u5ba2\u6237\u7aef\u4f8b\u7a0b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-04-19T16:36:18+00:00","dateModified":"2025-04-19T16:36:18+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/28482.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/28482.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/28482.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u3010ESP32\u3011ESP-IDF\u5f00\u53d1 | WiFi\u5f00\u53d1 | TCP\u4f20\u8f93\u63a7\u5236\u534f\u8bae + TCP\u670d\u52a1\u5668\u548c\u5ba2\u6237\u7aef\u4f8b\u7a0b"}]},{"@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\/28482","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=28482"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/28482\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/28472"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=28482"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=28482"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=28482"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=28482"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}