我已經建立了一個與websocket的連接,我想從它接收消息。以下是我從websocket接收消息的代碼。在websocket上使用TcpClient接收數據get 0 0 0 0
//mClient is my TCP connection
byte[] bytes;
NetworkStream netStream;
string returndata;
while(true)
{
bytes = new byte[mClient.ReceiveBufferSize];
netStream = mClient.GetStream();
netStream.Read(bytes, 0, (int)mClient.ReceiveBufferSize);
returndata = Encoding.UTF8.GetString(bytes);
Console.WriteLine("This is what the host returned to you: " + returndata);
}
的數據應該是一些JSON數組,當我和瀏覽器中打開,但我有收到這樣
??\0\0\0\0\0\0\0\0\0\0\
而第二循環開始是永遠
\ 0 \怪異數據0 \ 0 \ 0 \ 0 \ 0 \ 0
我看過一個Similar Question但是我不知道他的答案。我可以知道如何解決這個問題,這是什麼問題?