Java is big endian (the MSB (most significant byte) comes first). .Net appears to be little endian (LSB (least significant byte) comes first). But I don't think the standard really specifies anything. So, I guess it just defaults to whatever the native ordering is for the CPU. For Intel CPU's this is always little endian.
Anyhow, if you want little endian platforms to communicate with big endian platforms you have to use byte swapping (reverse the order of the bytes) on all numeric data that is passed back and forth between the two. This includes int's, doubles, floats, etc. etc. ----- Original Message ----- From: "Klammer Claus" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, October 23, 2002 5:13 AM Subject: [ADVANCED-DOTNET] host and network byte order? > I want to connect a midp device (java) with a server written in c#. > During tests I noticed that the writeInt method of the 2 languages differs. > At least the way the data is sent over the network is different. > I used a tcp sniffer to test this (sent int number '14'): > -----------------(java)------------------------------ > OUT: 4 bytes. > 0000 00 00 00 0E > -----------------(c#)-------------------------------- > OUT: 4 bytes. > 0000 0E 00 00 00 > > Can anyone explain this difference. Shouldn't all programs send data over > the network in 'network byte order'? Which programming language uses the > right byte order? > How can I accomplish network portability at all? > > Note, I tested local. Server and client (emulator) run on the same machine. > > Regards, > Claus Klammer > > You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced DOTNET, or > subscribe to other DevelopMentor lists at http://discuss.develop.com. > You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com.