Send a value by socket and read the value by reader.ReadInt32() changes value

前端 未结 2 1516
太阳男子
太阳男子 2020-12-20 10:35

I am trying to send a value by socket .So i have two parts in my project Client and server .

The client sends a value to serve

2条回答
  •  渐次进展
    2020-12-20 10:51

    and my values is like this :841757955

    Always worth sticking that number in the Windows calculator and convert that to hex. You get 0x322C3503.

    Which looks a lot like ASCII, a string with 3 characters that encodes "5,2". In other words, your real code doesn't resemble your snippet at all, you don't actually use the BinaryWriter.Write(Int32) overload, you used BinaryWriter.Write(String).

    Sure, that can't work, you can't write a string and expect it to be readable as raw integers. Fix your code.

提交回复
热议问题