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
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 */