Answer the question
In order to leave comments, you need to log in
WebSocket: how to convert byte to string when receiving?
I send the following message to the websocket server (from the client):
На C#
int test1 = 30;
int test2 = 40;
byte[] data = new byte[8];
byte[] testB1 = System.BitConverter.GetBytes(test1);
byte[] testB2 = System.BitConverter.GetBytes(test2);
testB1.CopyTo(data,0);
testB2.CopyTo(data,4);
webSocket.Send(data);
Пробовал вот так, но выдает какую-то ерунду, а не мои цифры
string result = Encoding.UTF8.GetString(data);
А вот так:
string result = BitConverter.ToString(data);
выдает хекс, но как его перевести в мои цифры не знаю.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question