{"id":15527,"date":"2025-04-18T22:02:16","date_gmt":"2025-04-18T14:02:16","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/15527.html"},"modified":"2025-04-18T22:02:16","modified_gmt":"2025-04-18T14:02:16","slug":"c-socket%e6%9c%8d%e5%8a%a1%e5%99%a8%e4%b8%8e%e5%ae%a2%e6%88%b7%e7%ab%af","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/15527.html","title":{"rendered":"C# Socket\u670d\u52a1\u5668\u4e0e\u5ba2\u6237\u7aef"},"content":{"rendered":"<h2>Socket\u901a\u4fe1<\/h2>\n<h3>\u6548\u679c\u5c55\u793a<\/h3>\n<p>\u200b\u200b<\/p>\n<p>QQ20241112-114846<\/p>\n<h3>Socket\u7684\u57fa\u672c\u6982\u5ff5<\/h3>\n<p>Socket&#xff1a;\u5b83\u662f\u7f51\u7edc\u901a\u4fe1\u7684\u4e00\u4e2a\u63a5\u53e3&#xff0c;\u4ee3\u8868\u4e86\u901a\u4fe1\u7684\u4e00\u4e2a\u7aef\u70b9\u3002\u53ef\u4ee5\u60f3\u8c61\u6210\u4e00\u6761\u865a\u62df\u7684\u7535\u8bdd\u7ebf&#xff0c;\u4e00\u7aef\u8fde\u63a5\u5ba2\u6237\u7aef&#xff0c;\u53e6\u4e00\u7aef\u8fde\u63a5\u670d\u52a1\u5668\u3002<\/p>\n<p>\u534f\u8bae&#xff1a;Socket\u53ef\u4ee5\u57fa\u4e8e\u591a\u79cd\u534f\u8bae\u8fdb\u884c\u901a\u4fe1&#xff0c;\u6700\u5e38\u7528\u7684\u662fTCP&#xff08;\u4f20\u8f93\u63a7\u5236\u534f\u8bae&#xff09;\u548cUDP&#xff08;\u7528\u6237\u6570\u636e\u62a5\u534f\u8bae&#xff09;\u3002TCP\u662f\u9762\u5411\u8fde\u63a5\u3001\u53ef\u9760\u7684\u534f\u8bae&#xff0c;\u800cUDP\u662f\u65e0\u8fde\u63a5\u3001\u5feb\u901f\u7684\u534f\u8bae\u3002<\/p>\n<h3>Socket\u901a\u4fe1\u7684\u57fa\u672c\u6d41\u7a0b<\/h3>\n<p>\u670d\u52a1\u7aef&#xff1a;<\/p>\n<li>\n<p>\u521b\u5efaSocket\u5bf9\u8c61&#xff1a;\u4f7f\u7528socket()\u51fd\u6570\u521b\u5efa\u5957\u63a5\u5b57\u3002<\/p>\n<\/li>\n<li>\n<p>\u7ed1\u5b9aIP\u5730\u5740\u548c\u7aef\u53e3\u53f7&#xff1a;\u4f7f\u7528bind()\u51fd\u6570\u5c06Socket\u7ed1\u5b9a\u5230\u6307\u5b9a\u7684IP\u548c\u7aef\u53e3\u3002<\/p>\n<\/li>\n<li>\n<p>\u76d1\u542c\u8fde\u63a5&#xff1a;\u4f7f\u7528listen()\u51fd\u6570\u5c06Socket\u8bbe\u7f6e\u4e3a\u76d1\u542c\u72b6\u6001&#xff0c;\u7b49\u5f85\u5ba2\u6237\u7aef\u8fde\u63a5\u3002<\/p>\n<\/li>\n<li>\n<p>\u63a5\u6536\u8fde\u63a5\u8bf7\u6c42&#xff1a;\u4f7f\u7528accept()\u51fd\u6570\u63a5\u6536\u5ba2\u6237\u7aef\u7684\u8fde\u63a5\u8bf7\u6c42&#xff0c;\u8fd4\u56de\u4e00\u4e2a\u65b0\u7684Socket\u5b9e\u4f8b&#xff0c;\u7528\u4e8e\u4e0e\u5ba2\u6237\u7aef\u901a\u4fe1\u3002<\/p>\n<\/li>\n<li>\n<p>\u5904\u7406\u6570\u636e\u901a\u4fe1&#xff1a;\u670d\u52a1\u7aef\u548c\u5ba2\u6237\u7aef\u901a\u8fc7send()\u548crecv()\u51fd\u6570\u8fdb\u884c\u6570\u636e\u4ea4\u6362\u3002<\/p>\n<\/li>\n<li>\n<p>\u5173\u95ed\u8fde\u63a5&#xff1a;\u901a\u4fe1\u7ed3\u675f\u540e&#xff0c;\u4f7f\u7528close()\u51fd\u6570\u5173\u95edSocket\u3002<\/p>\n<\/li>\n<p>\u5ba2\u6237\u7aef&#xff1a;<\/p>\n<li>\n<p>\u521b\u5efaSocket\u5bf9\u8c61&#xff1a;\u5ba2\u6237\u7aef\u4f7f\u7528socket()\u51fd\u6570\u521b\u5efa\u5957\u63a5\u5b57\u3002<\/p>\n<\/li>\n<li>\n<p>\u8fde\u63a5\u670d\u52a1\u5668&#xff1a;\u4f7f\u7528connect()\u51fd\u6570\u8fde\u63a5\u5230\u670d\u52a1\u5668\u7684IP\u5730\u5740\u548c\u7aef\u53e3\u3002<\/p>\n<\/li>\n<li>\n<p>\u6570\u636e\u901a\u4fe1&#xff1a;\u5ba2\u6237\u7aef\u4e0e\u670d\u52a1\u7aef\u901a\u8fc7send()\u548crecv()\u51fd\u6570\u4ea4\u6362\u6570\u636e\u3002<\/p>\n<\/li>\n<li>\n<p>\u5173\u95ed\u8fde\u63a5&#xff1a;\u901a\u4fe1\u7ed3\u675f\u540e\u5173\u95edSocket\u3002<\/p>\n<\/li>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"873\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418140215-68025b674569d.jpg\" width=\"692\" \/><\/p>\n<h2>\u793a\u4f8b\u4ee3\u7801<\/h2>\n<h3>Server\u670d\u52a1\u5668<\/h3>\n<h4>\u7a97\u4f53\u5c55\u793a<\/h4>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"610\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418140215-68025b6768b70.png\" width=\"938\" \/><\/p>\n<h4>\u67e5\u8be2\u672c\u673aIP\u5730\u5740<\/h4>\n<p>private void GetIp()\/\/\u83b7\u53d6\u672c\u673aip { string hostName &#061; Dns.GetHostName(); \/\/ \u83b7\u53d6\u672c\u673a\u540d\u79f0 IPAddress[] ipList &#061; Dns.GetHostAddresses(hostName);\/\/\u672c\u673aip&#xff08;\u5305\u62ecipv4\u548cipv6&#xff09;<\/p>\n<p> foreach (IPAddress ip in ipList) \u00a0 \u00a0 \u00a0  \/\/ foreach\u4e0d\u9700\u8981\u624b\u52a8\u7ba1\u7406\u7d22\u5f15<br \/>\n {<br \/>\n \u00a0 \u00a0 uiComboBox_IP.Items.Add(ip.ToString().Trim());<br \/>\n \u00a0 \u00a0 \/\/ .Trim()&#xff1a;\u53bb\u9664\u8f6c\u6362\u540e\u7684\u5b57\u7b26\u4e32\u9996\u5c3e\u7684\u7a7a\u767d\u5b57\u7b26<br \/>\n \u00a0 \u00a0 \/\/ &#xff08;\u867d\u7136\u901a\u5e38 IP \u5730\u5740\u5b57\u7b26\u4e32\u6ca1\u6709\u7a7a\u683c&#xff0c;\u8fd9\u91cc\u7528 .Trim() \u53ea\u662f\u66f4\u4fdd\u9669\u7684\u505a\u6cd5&#xff09;\u3002<br \/>\n }<br \/>\n\u200b<br \/>\n \/\/ \u67e5\u8be2IPV4&#xff0c;\u5c06\u67e5\u8be2\u5230\u7684\u7b2c\u4e00\u4e2aIP\u5b58\u653e\u5728\u6587\u672c\u6846\u4e2d<br \/>\n int index &#061; 0;<br \/>\n foreach (IPAddress ip in ipList)<br \/>\n {<br \/>\n \u00a0 \u00a0 if (ip.AddressFamily &#061;&#061; AddressFamily.InterNetwork)<br \/>\n \u00a0 \u00a0 {<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 break;<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 \/\/ \u67e5\u8be2\u5230\u7b2c\u4e00\u4e2a\u540e\u5c31 \u505c\u6b62<br \/>\n \u00a0 \u00a0 }<br \/>\n \u00a0 \u00a0 index&#043;&#043;;<br \/>\n }<br \/>\n uiComboBox_IP.SelectedIndex &#061; index;<br \/>\n uiTextBox_Port.Text &#061; &#034;8081&#034;;<br \/>\n} <\/p>\n<h4>\u521b\u5efaSocket()\u670d\u52a1\u5668<\/h4>\n<p>\/\/\/ &lt;summary&gt;<br \/>\n\/\/\/ \u5ba2\u6237\u7aef\u7684Socket<br \/>\n\/\/\/ &lt;\/summary&gt;<br \/>\nprivate Socket clientSocket;<br \/>\n\/\/ \u5b58\u50a85M\u5927\u5c0f\u7684\u6570\u636e<br \/>\nbyte[] buffer &#061; new byte[1024 * 1024 * 5];<br \/>\nprivate void btn_StartListen_Click(object sender, EventArgs e)<br \/>\n{<br \/>\n    \/\/AddressFamily&#8211;\u5730\u5740\u7c7b\u578b<br \/>\n    \/\/AddressFamily.InterNetwork&#8211;&gt;IPV4<br \/>\n    \/\/SocketType.Stream&#8211;&gt;\u4ee5\u5b57\u8282\u6d41\u7684\u65b9\u5f0f\u4f20\u8f93<br \/>\n    \/\/ProtocolType.Tcp&#8211;&gt;\u4f20\u8f93\u534f\u8bae; <\/p>\n<p>\/\/ 1.\u521b\u5efa\u670d\u52a1\u5668Socket()<br \/>\nSocket socket &#061;new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);<\/p>\n<p> \/\/ 2.\u7ed1\u5b9aIP\u548c\u7aef\u53e3Bind()<br \/>\n IPEndPoint endPoint &#061; new IPEndPoint(IPAddress.Parse(uiComboBox_IP.SelectedItem.ToString()), int.Parse(uiTextBox_Port.Text));<br \/>\n socket.Bind(endPoint);<br \/>\n\u200b<br \/>\n PrintfLog(&#034;\u7ed1\u5b9a\u7aef\u53e3\u548cIP\u6210\u529f&#034;);<br \/>\n\u200b<br \/>\n Console.WriteLine();<br \/>\n\u200b<br \/>\n \/\/ 3.\u76d1\u542c\u8fde\u63a5Listen()<br \/>\n socket.Listen(10);<br \/>\n\u200b<br \/>\n \/\/ \u63a5\u6536\u8fde\u63a5\u8bf7\u6c42 Accept()<br \/>\n \/\/ Task.Run\u4f1a\u5728\u7ebf\u7a0b\u6c60\u4e2d\u542f\u52a8\u4e00\u4e2a\u65b0\u4efb\u52a1<br \/>\n Task&lt;bool&gt; task &#061; Task.Run(() &#061;&gt;<br \/>\n {<br \/>\n \u00a0 \u00a0 while (true)<br \/>\n \u00a0 \u00a0 {<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 \/\/\u7b49\u5f85\u5ba2\u6237\u7aef\u5efa\u7acb\u8fde\u63a5<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 clientSocket&#061;socket.Accept();<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 PrintfLog(&#034;\u670d\u52a1\u5668\u4e0e\u5ba2\u6237\u7aef\u8fde\u63a5\u6210\u529f&#034;);<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 return true;<br \/>\n \u00a0 \u00a0 }<br \/>\n });<br \/>\n var awaiter&#061; task.GetAwaiter();<br \/>\n awaiter.OnCompleted(() &#061;&gt;<br \/>\n {<br \/>\n \u00a0 \u00a0 Task.Run(() &#061;&gt;<br \/>\n \u00a0 \u00a0 {<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 while (true)<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 {<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 clientSocket.Receive(buffer);<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 if (buffer.Length &#061;&#061; 0)<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 {<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 break;<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 }<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 string str &#061; Encoding.UTF8.GetString(buffer,0, buffer.Length);<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 PrintfLog(&#034;\u63a5\u53d7\u6570\u636e:&#034;&#043;str);<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 }<br \/>\n \u00a0 \u00a0 });<br \/>\n });<br \/>\n} <\/p>\n<h4>\u6587\u672c\u663e\u793a\u6846<\/h4>\n<p> void PrintfLog(string str)<br \/>\n  {<br \/>\n \u00a0 \u00a0  if (this.InvokeRequired)<br \/>\n \u00a0 \u00a0  {<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0  this.Invoke(new Action(() &#061;&gt;<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0  {<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0  \/\/ &#034;F&#034; \u662f\u6807\u51c6\u7684\u65e5\u671f\u548c\u65f6\u95f4\u683c\u5f0f\u5b57\u7b26\u4e32<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0  textBox_Log.AppendText(DateTime.Now.ToString(&#034;F&#034;) &#043; str &#043; &#034;\\\\r\\\\n&#034;);<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0  }));<br \/>\n \u00a0 \u00a0  }<br \/>\n \u00a0 \u00a0  else<br \/>\n \u00a0 \u00a0  {<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0  textBox_Log.AppendText(DateTime.Now.ToString(&#034;F&#034;) &#043; str &#043; &#034;\\\\r\\\\n&#034;);<br \/>\n \u00a0 \u00a0  }<br \/>\n  } <\/p>\n<h4>\u8f93\u5165\u680f<\/h4>\n<p>private void btn_Send_Click(object sender, EventArgs e) { string str &#061; textBox2.Text;<\/p>\n<p> byte [] buffer&#061;Encoding.UTF8.GetBytes(str);<br \/>\n\u200b<br \/>\n clientSocket.Send(buffer,buffer.Length,0);<br \/>\n\u200b<br \/>\n textBox2.Clear();<br \/>\n\u200b<br \/>\n textBox_Log.AppendText(DateTime.Now.ToString(&#034;F&#034;) &#043; &#034;\u53d1\u9001\u6570\u636e&gt;:&#034; &#043; str &#043; &#034;\\\\r\\\\n&#034;);<br \/>\n} <\/p>\n<h4>\u5173\u95ed<\/h4>\n<p>private void button1_Click(object sender, EventArgs e)<br \/>\n{<br \/>\n    this.Close();<br \/>\n} <\/p>\n<h4>\u5c0f\u5efa\u8bae\u00a0<\/h4>\n<p>\u53ef\u4ee5\u628a\u83b7\u53d6\u672c\u673aIP\u7684\u51fd\u6570\u653e\u5728Form1 \u6784\u9020\u51fd\u6570\u4e2d\u662f\u4e3a\u4e86\u5728\u7a97\u4f53\u542f\u52a8\u65f6\u81ea\u52a8\u83b7\u53d6\u5e76\u663e\u793a\u672c\u673a\u7684IP\u5730\u5740\u5217\u8868&#xff0c;\u4ee5\u4fbf\u7528\u6237\u53ef\u4ee5\u76f4\u63a5\u9009\u62e9\u4e00\u4e2aIP\u5730\u5740&#xff0c;\u65e0\u9700\u624b\u52a8\u8f93\u5165\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"220\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418140215-68025b6799fd8.png\" width=\"746\" \/><\/p>\n<h3>Client\u5ba2\u6237\u7aef<\/h3>\n<h4>\u7a97\u4f53\u5c55\u793a<\/h4>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"676\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418140215-68025b67aed1c.png\" width=\"853\" \/><\/p>\n<h4>connect()\u8fde\u63a5<\/h4>\n<p>private Socket soketSend;<br \/>\nbyte[] buff &#061; new byte[1024 * 1024 * 5];<br \/>\n Thread thread;<br \/>\nprivate void button1_Click(object sender, EventArgs e) {<br \/>\n    \/\/AddressFamily&#8211;\u5730\u5740\u7c7b\u578b<br \/>\n    \/\/AddressFamily.InterNetwork&#8211;&gt;IPV4<br \/>\n    \/\/SocketType.Stream&#8211;&gt;\u4ee5\u5b57\u8282\u6d41\u7684\u65b9\u5f0f\u4f20\u8f93<br \/>\n    \/\/ProtocolType.Tcp&#8211;&gt;\u4f20\u8f93\u534f\u8bae;<br \/>\n    soketSend &#061; new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);<\/p>\n<p> \/\/\u7ed1\u5b9a\u7aef\u53e3\u548cIP<br \/>\n IPEndPoint endPoint &#061; new IPEndPoint(IPAddress.Parse(textBox1.Text), int.Parse(textBox2.Text));<br \/>\n\u200b<br \/>\n soketSend.Connect(endPoint);<br \/>\n\u200b<br \/>\n textBox_log.AppendText(&#034;\u5ba2\u6237\u7aef\u8fde\u63a5\u670d\u52a1\u5668\u6210\u529f&#034; &#043; &#034;\\\\r\\\\n&#034;);<br \/>\n\u200b<br \/>\n thread &#061; new Thread(() &#061;&gt;<br \/>\n {<br \/>\n \u00a0 \u00a0 while (true)<br \/>\n \u00a0 \u00a0 {<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 \/\/Receive\u662f\u6709\u6548\u6570\u636e\u5f97\u957f\u5ea6<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 int len &#061; soketSend.Receive(buff);<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 if (len &#061;&#061; 0)<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 {<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 break;<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 }<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 string str &#061; Encoding.UTF8.GetString(buff, 0, len);<br \/>\n\u200b<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 this.Invoke(new Action(() &#061;&gt;<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 {<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 textBox_log.AppendText(DateTime.Now.ToString(&#034;F&#034;) &#043; &#034;\u63a5\u53d7\u670d\u52a1\u5668\u6d88\u606f:&#034; &#043; str &#043; &#034;\\\\r\\\\n&#034;);<br \/>\n \u00a0 \u00a0 \u00a0 \u00a0 }));<br \/>\n\u200b<br \/>\n \u00a0 \u00a0 }<br \/>\n });<br \/>\n thread.Start();<br \/>\n} <\/p>\n<h4>\u53d1\u9001\u6d88\u606fsend()<\/h4>\n<p>private void button2_Click(object sender, EventArgs e)<br \/>\n{<br \/>\n    string str &#061; textBox4.Text;<br \/>\n    byte[] bytes&#061; Encoding.UTF8.GetBytes(str);<br \/>\n    soketSend.Send(bytes); textBox4.Clear();<br \/>\n    textBox_log.AppendText(DateTime.Now.ToString(&#034;F&#034;) &#043; &#034;\u53d1\u9001\u670d\u52a1\u5668\u6d88\u606f:&#034; &#043; str &#043; &#034;\\\\r\\\\n&#034;);<br \/>\n } <\/p>\n<h4>\u5173\u95ed<\/h4>\n<p>private void close_Click(object sender, EventArgs e)<br \/>\n {<br \/>\n    this.Close();<br \/>\n} <\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.5k\u6b21\uff0c\u70b9\u8d5e17\u6b21\uff0c\u6536\u85cf5\u6b21\u3002\u200b\u200b\u3002_c# socket\u670d\u52a1\u7aef<\/p>\n","protected":false},"author":2,"featured_media":15523,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[55,43,78],"topic":[],"class_list":["post-15527","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-c","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>C# Socket\u670d\u52a1\u5668\u4e0e\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\/15527.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"C# Socket\u670d\u52a1\u5668\u4e0e\u5ba2\u6237\u7aef - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.5k\u6b21\uff0c\u70b9\u8d5e17\u6b21\uff0c\u6536\u85cf5\u6b21\u3002\u200b\u200b\u3002_c# socket\u670d\u52a1\u7aef\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/15527.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-18T14:02:16+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418140215-68025b674569d.jpg\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/15527.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/15527.html\",\"name\":\"C# Socket\u670d\u52a1\u5668\u4e0e\u5ba2\u6237\u7aef - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-04-18T14:02:16+00:00\",\"dateModified\":\"2025-04-18T14:02:16+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/15527.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/15527.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/15527.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"C# Socket\u670d\u52a1\u5668\u4e0e\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":"C# Socket\u670d\u52a1\u5668\u4e0e\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\/15527.html","og_locale":"zh_CN","og_type":"article","og_title":"C# Socket\u670d\u52a1\u5668\u4e0e\u5ba2\u6237\u7aef - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.5k\u6b21\uff0c\u70b9\u8d5e17\u6b21\uff0c\u6536\u85cf5\u6b21\u3002\u200b\u200b\u3002_c# socket\u670d\u52a1\u7aef","og_url":"https:\/\/www.wsisp.com\/helps\/15527.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-04-18T14:02:16+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418140215-68025b674569d.jpg"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/15527.html","url":"https:\/\/www.wsisp.com\/helps\/15527.html","name":"C# Socket\u670d\u52a1\u5668\u4e0e\u5ba2\u6237\u7aef - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-04-18T14:02:16+00:00","dateModified":"2025-04-18T14:02:16+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/15527.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/15527.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/15527.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"C# Socket\u670d\u52a1\u5668\u4e0e\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\/15527","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=15527"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/15527\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/15523"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=15527"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=15527"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=15527"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=15527"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}