How to set big-endian in Cocos2d-x?

Hi guys, I want to set up communication between mobile app and java, I chose socket with bytes stream.I found BSD socket is little-endian in IOS and Anroid, but Java side is big-endian.

How to set big-endian in cocos2d-x ? Thanks a lot.

I guess there is no easy way to switch to Big-Endiann mode. Depending on the API’s you use, you should convert your data to network-byte-order before sending it over the wire.
See http://www.gnu.org/software/libc/manual/html_node/Byte-Order.html
Network-Byte-Order for IP communication means Big-Endian

On your server side you must convert the data back to host byte order.
I’m not sure if the java does that automatically, at least it would explain your issues if you send little-endian data and the java side expexts to receive big-endian data and flips the data so it fits the host system.

Yes,you are right, I realized it on my server side like said.:slight_smile:

Many thanks for your warm answer and I’m sorry reply you so late until over Chinese New Year.