Breaking the exact message- java network programming

HI,
My server (Java socket using multi-thread processing) is receiving the huge traffic continuously and then I'm in a problem while breaking the exact message before processing.

Note : Each message has 2 byes header which labelled the length of the message and the socket connection type is persistence.
Example receiving buffer (00 0A is length)

00 0A xx xx xx.............00 0A xx xx ...............

In brief,
After reading the buffer, it's handing over to separate thread for breaking the message by its length. Once it's completed, the broken message will hander over to the processing.
READ_BUFF_SIZE = 10000;
byte[] buff = new byte[READ_BUFF_SIZE];
in = new DataInputStream(clientSocket.getInputStream());
int readLen = in.read(buff,0,READ_BUFF_SIZE);




The problem is that the next buffer sometimes does not start with message length then the message breaking is totally case me.

The next buffer sometimes as bellow

xx xx xx 00 0A xx xx xx............


So let me advice to avoid this situation and how like VISA/MC centeral transactions severs have been handled such huge traffic (Asking only programming technology since it may help me ) ?


Hope you understand my problem and waiting for your response.

Thanks

Comments

Sign In or Register to comment.