I have got problem with sending int from Java Client to C++ server. I don’t wan’t to change code of server (i hear something about htonl). Now sending from client 13928 (0011 0110 0110 1000) i recive on my server 6829568(0110 1000 0011 0110 0000 0000). Is there un Java any function similar to htonl ?
Share
Change the code of the server. It’s broken.
The problem is that the format the server “understands” will actually vary depending on its CPU architecture. Java is sending the standard network byte order, which is the right thing to do – the server then has to to
ntohl()to convert that to its internal format. Changing the client code to include assumptions about the server’s endianness is a really, really bad idea.