tcp路由器接收不到報文是怎么處理的?
TCP通信無法接收數據TCP通信無法接收數據,代碼如下:/// <summary>/// 聲明獲取事件的委托/// </summary>private delegate void SynReceive();/// <summary>/// 線程接收函數/// </summary>public void Receive(){try{string strRcv = "";// 聲明字節數組,一次接收數據的長度為1024字節 byte[] RcvBuffer = new byte[1024];//循環讀取,直到接收完所有數據 while (true){int bytes = socket.Receive(RcvBuffer, RcvBuffer.Length, 0);//讀取完成后退出循環 if (bytes <= 0)break;//將讀取的字節數轉換為字符串 strRcv += Encoding.ASCII.GetString(RcvBuffer,bytes,0);if (!txtRcv.InvokeRequired){txtRcv.AppendText(strRcv);}else{txtRcv.Invoke(new SynReceive(Receive));}}}catch (Exception ex){MessageBox.Show(ex.Message);}