I’m writing a socket gateway for the whole company, I will defined the message format as length+value, it means, the first 4 byte indicate the length of the value. If I use xsocket, how could I get the first 4 bytes, then use INonBlockingConnection.readStringByLength() to get the message?
Asked
Active
Viewed 77 times
1 Answers
0
At Interface INonBlockingConnection in the XSocket documentation, it suggests that you use ByteBuffer readByteBuffer to read larger amounts of data. Given that your whole company has to go through this gateway, processing data in blocks would seem more appropriate.
Your approach limits sends the length as a sequence of ASCII digits. You would be better placed to use the readInt()
method to retrieve a binary length from the stream.

Pekka
- 3,529
- 27
- 45