{"id":44583,"date":"2025-06-19T16:00:44","date_gmt":"2025-06-19T08:00:44","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/44583.html"},"modified":"2025-06-19T16:00:44","modified_gmt":"2025-06-19T08:00:44","slug":"php%e6%a1%88%e4%be%8b-tcp%e6%9c%8d%e5%8a%a1%e5%99%a8%e5%8d%8f%e8%ae%ae","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/44583.html","title":{"rendered":"php\u6848\u4f8b TCP\u670d\u52a1\u5668\u534f\u8bae"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250619080043-6853c3ab09589.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u89e3\u51b3\u65b9\u6cd5&#xff1a;\u542f\u7528 Telnet \u5ba2\u6237\u7aef \u6253\u5f00\u201c\u63a7\u5236\u9762\u677f\u201d \u2192 \u201c\u7a0b\u5e8f\u201d \u2192 \u201c\u542f\u7528\u6216\u5173\u95edWindows\u529f\u80fd\u201d \u627e\u5230\u201cTelnet\u5ba2\u6237\u7aef\u201d&#xff0c;\u52fe\u9009\u5b83&#xff0c;\u70b9\u51fb\u201c\u786e\u5b9a\u201d \u7b49\u5f85\u5b89\u88c5\u5b8c\u6210\u540e&#xff0c;\u91cd\u65b0\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26&#xff08;CMD&#xff09;&#xff0c;\u8f93\u5165 telnet&#xff0c;\u5982\u679c\u51fa\u73b0\u63d0\u793a\u8bf4\u660e\u5df2\u5b89\u88c5<\/p>\n<p>\u7b2c\u4e00\u6b65 D:&gt;D:\\\\phpstudy_pro\\\\Extensions\\\\php\\\\php7.4.3nts\\\\php.exe D:\\\\phpstudy_pro\\\\WWW\\\\1.php&#xff08;\u7136\u540e\u4e0d\u8981\u5173\u95ed&#xff09;<\/p>\n<p>\u7b2c\u4e8c\u6b65&#xff1a; \u53e6\u5916\u5728\u5f00\u542fcmd telnet 127.0.0.1 12345 <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250619080043-6853c3ab890fa.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h2>1.php<\/h2>\n<p><span class=\"token delimiter important\">&lt;?php<\/span><br \/>\n<span class=\"token variable\">$socket<\/span> <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">socket_create<\/span><span class=\"token punctuation\">(<\/span><span class=\"token constant\">AF_INET<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token constant\">SOCK_STREAM<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token constant\">SOL_TCP<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token function\">socket_bind<\/span><span class=\"token punctuation\">(<\/span><span class=\"token variable\">$socket<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string single-quoted-string\">&#039;0.0.0.0&#039;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">12345<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token function\">socket_listen<\/span><span class=\"token punctuation\">(<\/span><span class=\"token variable\">$socket<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">while<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token variable\">$conn<\/span> <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">socket_accept<\/span><span class=\"token punctuation\">(<\/span><span class=\"token variable\">$socket<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token function\">socket_write<\/span><span class=\"token punctuation\">(<\/span><span class=\"token variable\">$conn<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string double-quoted-string\">&#034;Hello TCP Client!\\\\n&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token function\">socket_close<\/span><span class=\"token punctuation\">(<\/span><span class=\"token variable\">$conn<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token function\">socket_close<\/span><span class=\"token punctuation\">(<\/span><span class=\"token variable\">$socket<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token operator\">?<\/span><span class=\"token operator\">&gt;<\/span><\/p>\n<p>\u89e3\u91ca&#xff1a; \u9010\u884c\u89e3\u91ca socket_create(AF_INET, SOCK_STREAM, SOL_TCP); \u521b\u5efa\u4e00\u4e2a\u57fa\u4e8e IPv4&#xff08;AF_INET&#xff09;\u3001\u6d41\u5f0f&#xff08;SOCK_STREAM&#xff09;\u3001TCP \u534f\u8bae&#xff08;SOL_TCP&#xff09;\u7684 socket\u3002 socket_bind(<span class=\"katex--inline\"><span class=\"katex\"><span class=\"katex-mathml\"> <\/p>\n<p>         s <\/p>\n<p>         o <\/p>\n<p>         c <\/p>\n<p>         k <\/p>\n<p>         e <\/p>\n<p>         t <\/p>\n<p>          , <\/p>\n<p>          \u2032 <\/p>\n<p>          0.0.0.0 <\/p>\n<p>          \u2032 <\/p>\n<p>         , <\/p>\n<p>         12345 <\/p>\n<p>         ) <\/p>\n<p>         ; <\/p>\n<p>         \u628a <\/p>\n<p>         s <\/p>\n<p>         o <\/p>\n<p>         c <\/p>\n<p>         k <\/p>\n<p>         e <\/p>\n<p>         t <\/p>\n<p>         \u7ed1\u5b9a\u5230\u672c\u5730\u6240\u6709 <\/p>\n<p>         I <\/p>\n<p>         P <\/p>\n<p>         \u7684 <\/p>\n<p>         12345 <\/p>\n<p>         \u7aef\u53e3\u4e0a\u3002\u8fd9\u6837&#xff0c;\u4efb\u4f55\u8bbf\u95ee\u672c\u673a <\/p>\n<p>         12345 <\/p>\n<p>         \u7aef\u53e3\u7684 <\/p>\n<p>         T <\/p>\n<p>         C <\/p>\n<p>         P <\/p>\n<p>         \u8fde\u63a5\u90fd\u80fd\u88ab\u8fd9\u4e2a <\/p>\n<p>         s <\/p>\n<p>         o <\/p>\n<p>         c <\/p>\n<p>         k <\/p>\n<p>         e <\/p>\n<p>         t <\/p>\n<p>         \u63a5\u6536\u3002 <\/p>\n<p>         s <\/p>\n<p>         o <\/p>\n<p>         c <\/p>\n<p>         k <\/p>\n<p>         e <\/p>\n<p>          t <\/p>\n<p>          l <\/p>\n<p>         i <\/p>\n<p>         s <\/p>\n<p>         t <\/p>\n<p>         e <\/p>\n<p>         n <\/p>\n<p>         ( <\/p>\n<p>        socket, &#039;0.0.0.0&#039;, 12345); \u628a socket \u7ed1\u5b9a\u5230\u672c\u5730\u6240\u6709 IP \u7684 12345 \u7aef\u53e3\u4e0a\u3002 \u8fd9\u6837&#xff0c;\u4efb\u4f55\u8bbf\u95ee\u672c\u673a 12345 \u7aef\u53e3\u7684 TCP \u8fde\u63a5\u90fd\u80fd\u88ab\u8fd9\u4e2a socket \u63a5\u6536\u3002 socket_listen( <\/p>\n<p>    <\/span><span class=\"katex-html\"><span class=\"base\"><span class=\"strut\" style=\"height: 1.0019em;vertical-align: -0.25em\"><\/span><span class=\"mord mathnormal\">soc<\/span><span style=\"margin-right: 0.0315em\" class=\"mord mathnormal\">k<\/span><span class=\"mord mathnormal\">e<\/span><span class=\"mord mathnormal\">t<\/span><span class=\"mpunct\"><span class=\"mpunct\">,<\/span><span class=\"msupsub\"><span class=\"vlist-t\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height: 0.7519em\"><span class=\"\" style=\"top: -3.063em;margin-right: 0.05em\"><span class=\"pstrut\" style=\"height: 2.7em\"><\/span><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mtight\"><span class=\"mord mtight\">\u2032<\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><span class=\"mspace\" style=\"margin-right: 0.1667em\"><\/span><span class=\"mord\">0.0.0.<\/span><span class=\"mord\"><span class=\"mord\">0<\/span><span class=\"msupsub\"><span class=\"vlist-t\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height: 0.7519em\"><span class=\"\" style=\"top: -3.063em;margin-right: 0.05em\"><span class=\"pstrut\" style=\"height: 2.7em\"><\/span><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mtight\"><span class=\"mord mtight\">\u2032<\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><\/span><span class=\"mpunct\">,<\/span><span class=\"mspace\" style=\"margin-right: 0.1667em\"><\/span><span class=\"mord\">12345<\/span><span class=\"mclose\">)<\/span><span class=\"mpunct\">;<\/span><span class=\"mspace\" style=\"margin-right: 0.1667em\"><\/span><span class=\"mord cjk_fallback\">\u628a<\/span><span class=\"mord mathnormal\">soc<\/span><span style=\"margin-right: 0.0315em\" class=\"mord mathnormal\">k<\/span><span class=\"mord mathnormal\">e<\/span><span class=\"mord mathnormal\">t<\/span><span class=\"mord cjk_fallback\">\u7ed1\u5b9a\u5230\u672c\u5730\u6240\u6709<\/span><span style=\"margin-right: 0.0785em\" class=\"mord mathnormal\">I<\/span><span style=\"margin-right: 0.1389em\" class=\"mord mathnormal\">P<\/span><span class=\"mord cjk_fallback\">\u7684<\/span><span class=\"mord\">12345<\/span><span class=\"mord cjk_fallback\">\u7aef\u53e3\u4e0a\u3002\u8fd9\u6837&#xff0c;\u4efb\u4f55\u8bbf\u95ee\u672c\u673a<\/span><span class=\"mord\">12345<\/span><span class=\"mord cjk_fallback\">\u7aef\u53e3\u7684<\/span><span style=\"margin-right: 0.1389em\" class=\"mord mathnormal\">TCP<\/span><span class=\"mord cjk_fallback\">\u8fde\u63a5\u90fd\u80fd\u88ab\u8fd9\u4e2a<\/span><span class=\"mord mathnormal\">soc<\/span><span style=\"margin-right: 0.0315em\" class=\"mord mathnormal\">k<\/span><span class=\"mord mathnormal\">e<\/span><span class=\"mord mathnormal\">t<\/span><span class=\"mord cjk_fallback\">\u63a5\u6536\u3002<\/span><span class=\"mord mathnormal\">soc<\/span><span style=\"margin-right: 0.0315em\" class=\"mord mathnormal\">k<\/span><span class=\"mord mathnormal\">e<\/span><span class=\"mord\"><span class=\"mord mathnormal\">t<\/span><span class=\"msupsub\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height: 0.3361em\"><span class=\"\" style=\"top: -2.55em;margin-left: 0em;margin-right: 0.05em\"><span class=\"pstrut\" style=\"height: 2.7em\"><\/span><span class=\"sizing reset-size6 size3 mtight\"><span style=\"margin-right: 0.0197em\" class=\"mord mathnormal mtight\">l<\/span><\/span><\/span><\/span><span class=\"vlist-s\">\u200b<\/span><\/span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height: 0.15em\"><span class=\"\"><\/span><\/span><\/span><\/span><\/span><\/span><span class=\"mord mathnormal\">i<\/span><span class=\"mord mathnormal\">s<\/span><span class=\"mord mathnormal\">t<\/span><span class=\"mord mathnormal\">e<\/span><span class=\"mord mathnormal\">n<\/span><span class=\"mopen\">(<\/span><\/span><\/span><\/span><\/span>socket); \u8ba9 socket \u8fdb\u5165\u76d1\u542c\u72b6\u6001&#xff0c;\u51c6\u5907\u63a5\u53d7\u5ba2\u6237\u7aef\u7684\u8fde\u63a5\u3002 while (<span class=\"katex--inline\"><span class=\"katex\"><span class=\"katex-mathml\"> <\/p>\n<p>         c <\/p>\n<p>         o <\/p>\n<p>         n <\/p>\n<p>         n <\/p>\n<p>         &#061; <\/p>\n<p>         s <\/p>\n<p>         o <\/p>\n<p>         c <\/p>\n<p>         k <\/p>\n<p>         e <\/p>\n<p>          t <\/p>\n<p>          a <\/p>\n<p>         c <\/p>\n<p>         c <\/p>\n<p>         e <\/p>\n<p>         p <\/p>\n<p>         t <\/p>\n<p>         ( <\/p>\n<p>        conn &#061; socket_accept( <\/p>\n<p>    <\/span><span class=\"katex-html\"><span class=\"base\"><span class=\"strut\" style=\"height: 0.4306em\"><\/span><span class=\"mord mathnormal\">co<\/span><span class=\"mord mathnormal\">nn<\/span><span class=\"mspace\" style=\"margin-right: 0.2778em\"><\/span><span class=\"mrel\">&#061;<\/span><span class=\"mspace\" style=\"margin-right: 0.2778em\"><\/span><\/span><span class=\"base\"><span class=\"strut\" style=\"height: 1em;vertical-align: -0.25em\"><\/span><span class=\"mord mathnormal\">soc<\/span><span style=\"margin-right: 0.0315em\" class=\"mord mathnormal\">k<\/span><span class=\"mord mathnormal\">e<\/span><span class=\"mord\"><span class=\"mord mathnormal\">t<\/span><span class=\"msupsub\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height: 0.1514em\"><span class=\"\" style=\"top: -2.55em;margin-left: 0em;margin-right: 0.05em\"><span class=\"pstrut\" style=\"height: 2.7em\"><\/span><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mathnormal mtight\">a<\/span><\/span><\/span><\/span><span class=\"vlist-s\">\u200b<\/span><\/span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height: 0.15em\"><span class=\"\"><\/span><\/span><\/span><\/span><\/span><\/span><span class=\"mord mathnormal\">cce<\/span><span class=\"mord mathnormal\">pt<\/span><span class=\"mopen\">(<\/span><\/span><\/span><\/span><\/span>socket)) { \u2026 } \u8fdb\u5165\u4e00\u4e2a\u6b7b\u5faa\u73af&#xff0c;\u4e0d\u65ad\u7b49\u5f85\u5ba2\u6237\u7aef\u8fde\u63a5\u3002 \u6bcf\u5f53\u6709\u5ba2\u6237\u7aef\u8fde\u63a5\u65f6&#xff0c;socket_accept \u4f1a\u8fd4\u56de\u4e00\u4e2a\u65b0\u7684\u8fde\u63a5\u8d44\u6e90 <span class=\"katex--inline\"><span class=\"katex\"><span class=\"katex-mathml\"> <\/p>\n<p>         c <\/p>\n<p>         o <\/p>\n<p>         n <\/p>\n<p>         n <\/p>\n<p>         \u3002 <\/p>\n<p>         s <\/p>\n<p>         o <\/p>\n<p>         c <\/p>\n<p>         k <\/p>\n<p>         e <\/p>\n<p>          t <\/p>\n<p>          w <\/p>\n<p>         r <\/p>\n<p>         i <\/p>\n<p>         t <\/p>\n<p>         e <\/p>\n<p>         ( <\/p>\n<p>        conn\u3002 socket_write( <\/p>\n<p>    <\/span><span class=\"katex-html\"><span class=\"base\"><span class=\"strut\" style=\"height: 1em;vertical-align: -0.25em\"><\/span><span class=\"mord mathnormal\">co<\/span><span class=\"mord mathnormal\">nn<\/span><span class=\"mord cjk_fallback\">\u3002<\/span><span class=\"mord mathnormal\">soc<\/span><span style=\"margin-right: 0.0315em\" class=\"mord mathnormal\">k<\/span><span class=\"mord mathnormal\">e<\/span><span class=\"mord\"><span class=\"mord mathnormal\">t<\/span><span class=\"msupsub\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height: 0.1514em\"><span class=\"\" style=\"top: -2.55em;margin-left: 0em;margin-right: 0.05em\"><span class=\"pstrut\" style=\"height: 2.7em\"><\/span><span class=\"sizing reset-size6 size3 mtight\"><span style=\"margin-right: 0.0269em\" class=\"mord mathnormal mtight\">w<\/span><\/span><\/span><\/span><span class=\"vlist-s\">\u200b<\/span><\/span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height: 0.15em\"><span class=\"\"><\/span><\/span><\/span><\/span><\/span><\/span><span style=\"margin-right: 0.0278em\" class=\"mord mathnormal\">r<\/span><span class=\"mord mathnormal\">i<\/span><span class=\"mord mathnormal\">t<\/span><span class=\"mord mathnormal\">e<\/span><span class=\"mopen\">(<\/span><\/span><\/span><\/span><\/span>conn, \u201cHello TCP Client!\\\\n\u201d); \u5411\u521a\u521a\u8fde\u63a5\u8fdb\u6765\u7684\u5ba2\u6237\u7aef\u53d1\u9001\u4e00\u6761\u6d88\u606f&#xff1a;\u201cHello TCP Client!\u201d socket_close(<span class=\"katex--inline\"><span class=\"katex\"><span class=\"katex-mathml\"> <\/p>\n<p>         c <\/p>\n<p>         o <\/p>\n<p>         n <\/p>\n<p>         n <\/p>\n<p>         ) <\/p>\n<p>         ; <\/p>\n<p>         \u5173\u95ed\u4e0e\u5f53\u524d\u5ba2\u6237\u7aef\u7684\u8fde\u63a5\u3002 <\/p>\n<p>         s <\/p>\n<p>         o <\/p>\n<p>         c <\/p>\n<p>         k <\/p>\n<p>         e <\/p>\n<p>          t <\/p>\n<p>          c <\/p>\n<p>         l <\/p>\n<p>         o <\/p>\n<p>         s <\/p>\n<p>         e <\/p>\n<p>         ( <\/p>\n<p>        conn); \u5173\u95ed\u4e0e\u5f53\u524d\u5ba2\u6237\u7aef\u7684\u8fde\u63a5\u3002 socket_close( <\/p>\n<p>    <\/span><span class=\"katex-html\"><span class=\"base\"><span class=\"strut\" style=\"height: 1em;vertical-align: -0.25em\"><\/span><span class=\"mord mathnormal\">co<\/span><span class=\"mord mathnormal\">nn<\/span><span class=\"mclose\">)<\/span><span class=\"mpunct\">;<\/span><span class=\"mspace\" style=\"margin-right: 0.1667em\"><\/span><span class=\"mord cjk_fallback\">\u5173\u95ed\u4e0e\u5f53\u524d\u5ba2\u6237\u7aef\u7684\u8fde\u63a5\u3002<\/span><span class=\"mord mathnormal\">soc<\/span><span style=\"margin-right: 0.0315em\" class=\"mord mathnormal\">k<\/span><span class=\"mord mathnormal\">e<\/span><span class=\"mord\"><span class=\"mord mathnormal\">t<\/span><span class=\"msupsub\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height: 0.1514em\"><span class=\"\" style=\"top: -2.55em;margin-left: 0em;margin-right: 0.05em\"><span class=\"pstrut\" style=\"height: 2.7em\"><\/span><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mathnormal mtight\">c<\/span><\/span><\/span><\/span><span class=\"vlist-s\">\u200b<\/span><\/span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height: 0.15em\"><span class=\"\"><\/span><\/span><\/span><\/span><\/span><\/span><span style=\"margin-right: 0.0197em\" class=\"mord mathnormal\">l<\/span><span class=\"mord mathnormal\">ose<\/span><span class=\"mopen\">(<\/span><\/span><\/span><\/span><\/span>socket); \u5f53\u5faa\u73af\u7ed3\u675f\u540e&#xff08;\u4e00\u822c\u4e0d\u4f1a\u7ed3\u675f&#xff09;&#xff0c;\u5173\u95ed\u4e3b socket\u3002 \u603b\u7ed3 \u8fd9\u6bb5\u4ee3\u7801\u5c31\u662f\u4e00\u4e2aTCP\u670d\u52a1\u5668&#xff0c;\u76d1\u542c 12345 \u7aef\u53e3\u3002 \u6bcf\u5f53\u6709\u5ba2\u6237\u7aef&#xff08;\u6bd4\u5982\u7528 telnet\u3001nc \u7b49\u5de5\u5177&#xff09;\u8fde\u63a5\u5230\u8fd9\u4e2a\u7aef\u53e3\u65f6&#xff0c;\u670d\u52a1\u5668\u4f1a\u56de\u590d\u4e00\u6761\u201cHello TCP Client!\u201d\u6d88\u606f&#xff0c;\u7136\u540e\u65ad\u5f00\u8fde\u63a5\u3002 \u9002\u5408\u7528\u6765\u5b66\u4e60 socket \u7f16\u7a0b\u7684\u57fa\u672c\u539f\u7406\u3002<\/p>\n<p>\u4ec0\u4e48\u662fTCP?<\/p>\n<li>TCP \u662f\u4ec0\u4e48&#xff1f; TCP \u662f\u4e00\u79cd\u7f51\u7edc\u901a\u4fe1\u534f\u8bae&#xff0c;\u5c5e\u4e8e\u4e92\u8054\u7f51\u534f\u8bae\u65cf&#xff08;TCP\/IP\u534f\u8bae\u65cf&#xff09;\u4e2d\u7684\u6838\u5fc3\u534f\u8bae\u4e4b\u4e00\u3002 \u5b83\u4e3b\u8981\u7528\u4e8e\u4e24\u53f0\u8ba1\u7b97\u673a\u4e4b\u95f4\u53ef\u9760\u5730\u4f20\u8f93\u6570\u636e&#xff0c;\u6bd4\u5982\u4f60\u8bbf\u95ee\u7f51\u9875\u3001\u6536\u53d1\u90ae\u4ef6\u3001\u6587\u4ef6\u4f20\u8f93\u7b49&#xff0c;\u5e95\u5c42\u90fd\u662f\u7528 TCP\u3002<\/li>\n<li>TCP \u7684\u4e3b\u8981\u7279\u70b9 \u9762\u5411\u8fde\u63a5 \u5728\u901a\u4fe1\u524d&#xff0c;\u5fc5\u987b\u5148\u5efa\u7acb\u8fde\u63a5&#xff08;\u4e09\u6b21\u63e1\u624b&#xff09;&#xff0c;\u901a\u4fe1\u7ed3\u675f\u540e\u8981\u65ad\u5f00\u8fde\u63a5&#xff08;\u56db\u6b21\u6325\u624b&#xff09;\u3002 \u53ef\u9760\u4f20\u8f93 \u6570\u636e\u4f20\u8f93\u6709\u786e\u8ba4\u673a\u5236\u3001\u91cd\u53d1\u673a\u5236\u3001\u987a\u5e8f\u63a7\u5236&#xff0c;\u4fdd\u8bc1\u6570\u636e\u4e0d\u4f1a\u4e22\u5931\u3001\u4e0d\u4f1a\u4e71\u5e8f\u3002 \u9762\u5411\u5b57\u8282\u6d41 \u6570\u636e\u4ee5\u5b57\u8282\u6d41\u7684\u65b9\u5f0f\u4f20\u8f93&#xff0c;\u6ca1\u6709\u6d88\u606f\u8fb9\u754c&#xff0c;\u5e94\u7528\u5c42\u9700\u8981\u81ea\u5df1\u5212\u5206\u6d88\u606f\u3002 \u5168\u53cc\u5de5\u901a\u4fe1 \u53cc\u65b9\u53ef\u4ee5\u540c\u65f6\u53d1\u9001\u548c\u63a5\u6536\u6570\u636e\u3002<\/li>\n<li>TCP \u7684\u5e94\u7528\u573a\u666f \u7f51\u9875\u6d4f\u89c8&#xff08;HTTP\/HTTPS \u534f\u8bae\u5e95\u5c42\u7528 TCP&#xff09; \u6587\u4ef6\u4f20\u8f93&#xff08;FTP \u534f\u8bae\u5e95\u5c42\u7528 TCP&#xff09; \u8fdc\u7a0b\u767b\u5f55&#xff08;SSH\u3001Telnet&#xff09; \u7535\u5b50\u90ae\u4ef6&#xff08;SMTP\u3001POP3\u3001IMAP&#xff09;<\/li>\n<li>TCP \u4e0e UDP \u7684\u533a\u522b | \u7279\u70b9 | TCP | UDP | |&#8212;&#8212;&#8212;&#8212;&#8211;|&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;|&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;| | \u662f\u5426\u8fde\u63a5 | \u6709\u8fde\u63a5&#xff08;\u4e09\u6b21\u63e1\u624b&#xff09; | \u65e0\u8fde\u63a5 | | \u662f\u5426\u53ef\u9760 | \u53ef\u9760&#xff0c;\u4fdd\u8bc1\u987a\u5e8f\u548c\u5b8c\u6574\u6027 | \u4e0d\u53ef\u9760&#xff0c;\u53ef\u80fd\u4e22\u5305\u3001\u4e71\u5e8f | | \u901f\u5ea6 | \u8f83\u6162 | \u8f83\u5feb | | \u5e94\u7528\u573a\u666f | \u7f51\u9875\u3001\u6587\u4ef6\u3001\u90ae\u4ef6\u7b49 | \u89c6\u9891\u3001\u8bed\u97f3\u3001\u76f4\u64ad\u3001\u6e38\u620f\u7b49 |<\/li>\n<li>\u5f62\u8c61\u7406\u89e3 \u4f60\u53ef\u4ee5\u628a TCP \u60f3\u8c61\u6210\u6253\u7535\u8bdd&#xff1a; \u5148\u62e8\u53f7&#xff08;\u5efa\u7acb\u8fde\u63a5&#xff09;&#xff0c;\u5bf9\u65b9\u63a5\u542c\u540e\u624d\u80fd\u8bf4\u8bdd&#xff08;\u6570\u636e\u4f20\u8f93&#xff09;&#xff0c;\u8bf4\u5b8c\u6302\u7535\u8bdd&#xff08;\u65ad\u5f00\u8fde\u63a5&#xff09;&#xff0c;\u6bcf\u53e5\u8bdd\u90fd\u80fd\u786e\u8ba4\u5bf9\u65b9\u542c\u5230\u4e86\u3002 \u800c UDP \u50cf\u53d1\u77ed\u4fe1&#xff1a; \u76f4\u63a5\u53d1&#xff0c;\u4e0d\u7ba1\u5bf9\u65b9\u6536\u6ca1\u6536\u5230&#xff0c;\u4e5f\u4e0d\u4fdd\u8bc1\u987a\u5e8f\u3002<\/li>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb816\u6b21\uff0c\u70b9\u8d5e27\u6b21\uff0c\u6536\u85cf19\u6b21\u3002\u89e3\u51b3\u65b9\u6cd5\uff1a\u542f\u7528 Telnet \u5ba2\u6237\u7aef\u6253\u5f00\u201c\u63a7\u5236\u9762\u677f\u201d \u2192 \u201c\u7a0b\u5e8f\u201d \u2192 \u201c\u542f\u7528\u6216\u5173\u95edWindows\u529f\u80fd\u201d\u627e\u5230\u201cTelnet\u5ba2\u6237\u7aef\u201d\uff0c\u52fe\u9009\u5b83\uff0c\u70b9\u51fb\u201c\u786e\u5b9a\u201d\u7b49\u5f85\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u91cd\u65b0\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\uff08CMD\uff09\uff0c\u8f93\u5165 telnet\uff0c\u5982\u679c\u51fa\u73b0\u63d0\u793a\u8bf4\u660e\u5df2\u5b89\u88c5\u7b2c\u4e00\u6b65D:&gt;D:\\\\phpstudy_pro\\\\Extensions\\\\php\\\\php7.4.3nts\\\\php.exe    D:\\\\phpstudy_pro\\\\WWW\\\\1.php\uff08\u7136\u540e\u4e0d\u8981\u5173\u95ed\uff09\u7b2c\u4e8c\u6b65\uff1a\u53e6\u5916\u5728\u5f00\u542fcmd\u3002_php tcp \u670d\u52a1\u5668<\/p>\n","protected":false},"author":2,"featured_media":44581,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[230,4183,970,4184],"topic":[],"class_list":["post-44583","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-php","tag-php100","tag-tcp","tag-4184"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>php\u6848\u4f8b TCP\u670d\u52a1\u5668\u534f\u8bae - \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\/44583.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"php\u6848\u4f8b TCP\u670d\u52a1\u5668\u534f\u8bae - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb816\u6b21\uff0c\u70b9\u8d5e27\u6b21\uff0c\u6536\u85cf19\u6b21\u3002\u89e3\u51b3\u65b9\u6cd5\uff1a\u542f\u7528 Telnet \u5ba2\u6237\u7aef\u6253\u5f00\u201c\u63a7\u5236\u9762\u677f\u201d \u2192 \u201c\u7a0b\u5e8f\u201d \u2192 \u201c\u542f\u7528\u6216\u5173\u95edWindows\u529f\u80fd\u201d\u627e\u5230\u201cTelnet\u5ba2\u6237\u7aef\u201d\uff0c\u52fe\u9009\u5b83\uff0c\u70b9\u51fb\u201c\u786e\u5b9a\u201d\u7b49\u5f85\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u91cd\u65b0\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\uff08CMD\uff09\uff0c\u8f93\u5165 telnet\uff0c\u5982\u679c\u51fa\u73b0\u63d0\u793a\u8bf4\u660e\u5df2\u5b89\u88c5\u7b2c\u4e00\u6b65D:&gt;D:\\phpstudy_pro\\Extensions\\php\\php7.4.3nts\\php.exe  D:\\phpstudy_pro\\WWW\\1.php\uff08\u7136\u540e\u4e0d\u8981\u5173\u95ed\uff09\u7b2c\u4e8c\u6b65\uff1a\u53e6\u5916\u5728\u5f00\u542fcmd\u3002_php tcp \u670d\u52a1\u5668\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/44583.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-06-19T08:00:44+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250619080043-6853c3ab09589.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=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/44583.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/44583.html\",\"name\":\"php\u6848\u4f8b TCP\u670d\u52a1\u5668\u534f\u8bae - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-06-19T08:00:44+00:00\",\"dateModified\":\"2025-06-19T08:00:44+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/44583.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/44583.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/44583.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"php\u6848\u4f8b TCP\u670d\u52a1\u5668\u534f\u8bae\"}]},{\"@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":"php\u6848\u4f8b TCP\u670d\u52a1\u5668\u534f\u8bae - \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\/44583.html","og_locale":"zh_CN","og_type":"article","og_title":"php\u6848\u4f8b TCP\u670d\u52a1\u5668\u534f\u8bae - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb816\u6b21\uff0c\u70b9\u8d5e27\u6b21\uff0c\u6536\u85cf19\u6b21\u3002\u89e3\u51b3\u65b9\u6cd5\uff1a\u542f\u7528 Telnet \u5ba2\u6237\u7aef\u6253\u5f00\u201c\u63a7\u5236\u9762\u677f\u201d \u2192 \u201c\u7a0b\u5e8f\u201d \u2192 \u201c\u542f\u7528\u6216\u5173\u95edWindows\u529f\u80fd\u201d\u627e\u5230\u201cTelnet\u5ba2\u6237\u7aef\u201d\uff0c\u52fe\u9009\u5b83\uff0c\u70b9\u51fb\u201c\u786e\u5b9a\u201d\u7b49\u5f85\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u91cd\u65b0\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\uff08CMD\uff09\uff0c\u8f93\u5165 telnet\uff0c\u5982\u679c\u51fa\u73b0\u63d0\u793a\u8bf4\u660e\u5df2\u5b89\u88c5\u7b2c\u4e00\u6b65D:&gt;D:\\phpstudy_pro\\Extensions\\php\\php7.4.3nts\\php.exe  D:\\phpstudy_pro\\WWW\\1.php\uff08\u7136\u540e\u4e0d\u8981\u5173\u95ed\uff09\u7b2c\u4e8c\u6b65\uff1a\u53e6\u5916\u5728\u5f00\u542fcmd\u3002_php tcp \u670d\u52a1\u5668","og_url":"https:\/\/www.wsisp.com\/helps\/44583.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-06-19T08:00:44+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250619080043-6853c3ab09589.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/44583.html","url":"https:\/\/www.wsisp.com\/helps\/44583.html","name":"php\u6848\u4f8b TCP\u670d\u52a1\u5668\u534f\u8bae - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-06-19T08:00:44+00:00","dateModified":"2025-06-19T08:00:44+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/44583.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/44583.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/44583.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"php\u6848\u4f8b TCP\u670d\u52a1\u5668\u534f\u8bae"}]},{"@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\/44583","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=44583"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/44583\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/44581"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=44583"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=44583"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=44583"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=44583"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}