Network Byte Order and data formatting
by, 04-25-2012 at 10:26 PM (1539 Views)
Before discussing Java Socket communication, a strong need is present to discuss the Network byte ordering issues. It is essential as the application and network usually do the interpretation of data is various ways. Network byte order is considered to be a standard way where network communication is done by the help of bytes ordering. Order is presented by it where bytes shall be written, when they are sent across networks. According to the byte order, higher bytes shall be written first and lower bytes shall be written last.
Data types shall also be considered when communication is done b/w a java client and an application that has been written in some other language. Due to neutrality of the platform, some data types are stored by Java in unfamiliar formats. 16bit char is considered as most obvious that is basically Unicode format character, not ASCII format. UTF i.e Unicode Text Format is encoding format which is quite larger to present various language characters, not English only. Hence it is required that data that is needed to be sent shall not be UTF and id shall be decoded before sending, if required. Java filter streams shall be used to do so.