How to seperate several messages in a byte buffer
I send messages through socket. For each read operation, several messags might be queued in a byte buffer at one time. I use a special character '^' which ascii value is 94 as a seperator. The problem is that the message id is integer. When the message id is 94, there is an exception when I try to use the seperator '^' to seperate messages.
Is there any good way to solve this problem?
thanks.
Re: How to seperate several messages in a byte buffer
How about using more than one character to separate the messages or use a proper serialization library to serialize your objects for you.
// Json
Re: How to seperate several messages in a byte buffer
Hello perl0101.
I have moved this thread to - Java Networking
Why not check the message ID before anything is processed? If it's 94, update it to something else.
Re: How to seperate several messages in a byte buffer
Than you for your suggestions. I will experiment with it today.
Re: How to seperate several messages in a byte buffer