我想空讀所以我寫後續碼插座的緩衝... byte[] tempBuffer = new byte[1024];
int readCount = 0;
while ((readCount = tcpSocket.GetStream().Read(tempBuffer, 0, tempBuffer.Length)) != 0)
{
// do with tempBuffer
}
我有一個字節數組,我從NetworkStream中讀取數據。前兩個字節表示隨後的數據包的長度,然後將數據包讀入該長度的字節數組中。我需要從NetworkStream/byte數組中讀取的數據有幾個字符串,即可變長度數據以新行字符結尾,以及一些固定寬度的字段,如字節和長整型。所以,這樣的事情: // I would have delimited these for clarity but I did