Byte order java / .net

When sending information from a java application to a C # application through sockets, is the byte order different? Or can I just send an integer from C # to a java application and read it as an integer?

(And do the OS do the value or the same thing for java / .net no matter how it works with the operating system?)

+3
source share
4 answers

It all comes down to how you encode the data. If you process only as an unprocessed sequence of bytes, there is no conflict; the sequence is the same. When questions are in endianness, when pieces of data are interpreted as (for example) integers.

, , - , ( Java, #) .

, , ( ), .

, . , ( ). , .NET BitConverter - , , ( Mono - ) . , .IsLittleEndian.

, , p

+7

Java Big Endian , DataInput/OutputStream. IP- Big Endian, Big Endian .

NIO ByteBuffer BigEndian, LittleEndian NativeEndian ( , )

x86 , , endian, Microsoft/Linux endian, big-endian.

+3
source

Yes, the byte order may vary. C # suggests that little-endian can use the byte order in the platform, Java tends to use big-endian. This has been discussed earlier on SO. See for example C # little endian or big endian?

0
source

All Articles