Java DataInputStream readInt() from C++ Client getting huge value

后端 未结 1 1089
说谎
说谎 2021-01-27 06:42

I suspect this has to do with endianness but I\'m not sure how to fix it. I have a C++ client telling a Java server how many bytes it\'s about to send where the Java server just

相关标签:
1条回答
  • 2021-01-27 07:13

    Try running the number through htonl before sending it (on the C++ side):

    long x = htonl(42); /* x now contains 42 represented in network byte order */
    
    0 讨论(0)
提交回复
热议问题