Reputation: 67
It seems that I can't figure out, why am I getting first packet splitted, and the rest of the packets I receive as one.
The first received thing is IMEI (17 bytes), the netty server sends back 01 respond and starts sending the packets, which I respond to them with another respond.
But why do I keep getting first packet in two parts ? While others are being send as one (which is ok). It always receives up to 1024 bytes and then the rest of 251 bytes . The whole package is up to 1275 bytes..
Upvotes: 0
Views: 357
Reputation: 23557
Generally speaking there is not guarantee if a packet is split or not when using TCP. So you can not make any assumptions on this.
That said what you see may be the result of using AdaptiveRecvByteBufAllocator
(which is the default) as it starts with small allocation sizes and then increase these if needed.
You could use a different RecvByteBufAllocator
if you want to change the behaviour. But again this is nothing you can depend on.
Upvotes: 1