1. in byte order, C ++ has different byte order on different platforms, x86 is little-Endian, and Solaris is big-Endian; java is big-Endian by default on all platforms. Therefore, when transmitting data such as short, Int, and long, it must be converted to the network Order (big-Endian) in C ++)
2. the most common character encoding in C ++ is MBCS, while Unicode is used in Java (and there are some differences from standard Unicode. For details, refer to the Java documentation ), therefore, do not upload strings unless necessary. You can upload text files instead. If you must transfer strings, you can only convert them yourself.
3. memory alignment. in C/C ++ network communication programs, the read/write structure is often used to conveniently exchange data. However, if you do not pay attention to it, there may be gaps in the structure, for example, struct a {int A; char c}; struct B {char a; int B}; there are gaps in both structures, if it is not stated that the Java program does not know the existence of the gap, it will cause errors during parsing by both parties. to eliminate gaps, you should be careful to arrange the structure members. We do not recommend using # pragma Pach (1) because it is not universal.
4. bit Field, unless careful, the structure size caused by bit field is related to the platform. The Bytes occupied by int A: 4 change with the platform and compiler (char: 4 relatively stable occupies 1 byte)
5. (may be platform-related) the transmission speed is different from the receiving speed. When C ++ transfers a large amount of data to Java, the C ++ side may have been passed out, java has been confiscated, leading to the loss of the last part of data. therefore, the project adopts a simple validation mechanism. After receiving the data, either party returns the 1-byte confirmation to prevent premature exit of C ++.
6. (may be platform-related) after Java establishes a connection with C ++ and transmits a piece of data to Java, if Java transmits a piece of data to C ++, C ++ receives only one byte of the data for the first time, and returns to normal after the first time.