Alexander wrote:
*What are the semantics of the messageReceived method (without
filters)? Will you receive one message per TCP package? Will the same
ByteBuffer always be reused for the whole message?
The message handed to messageReceived consists of whatever the network
stack of your operating system was fit. It has no necessary relation to
IP packets. There are certainly no guarantees that each IP-packetful of
the TCP stream will be received as a separate ByteBuffer.
In fact, the operating system is free to give you one byte at a time if
it wants to. Or give you as much data as fits into your read buffer. Or
alternate between these modes. A sane operating system would likely give
you whatever is in its buffers, provided it fits into the buffer you
gave the syscall. However, the only guarantees you can have of this are
implementation-specific, and the onyl control you have is the read
buffer size.
How are the
positions you set interpreted, and will they be reset? This has been
hinted on this list and in the tutorial for ProtocolDecoder, but more
thorough documentation would be handy.
My impression is that each message (ie. ByteBuffer) delivered to
IoHandler/IoFilter via messageReceived is independent - whatever the
handler/filter does with them is its business. I.e. MINA shouldn't touch
a buffer it has given you a reference to.
Basically I'm worried about not getting the header in one buffer
(HTTP header), so it would be fragmented between two ByteBuffers. Is
this possible? Is there a size limit or so? What if you get a huge
header?
Certainly it can be fragmented and delivered over multiple ByteBuffers.
*How are you supposed to handle mixed high/low level protocols? For
instance, if you write a HTTP proxy based on header contents, you need
to parse the header into an object at first (maybe using
MessageDecoder)? When the subsequent packages arrive, you will want to
stream them directly.
I'm not sure what you mean by high/low level protocols here. To me it
seems that you only mentioned HTTP. What is the higher/lower level here?