Trustin Lee wrote:
On 6/11/07, Bruno Colin <[EMAIL PROTECTED]> wrote:
Hello,

I'm currently developing a UDP server using MINA 2.0.
After having done some tests, I have some question on how MINA handles UDP.

By definition, I think that the maximum size of a UDP datagram
(with headers) is 65536 bytes, if we try to write a bigger message we
would have the
following exception: "Throwable java.net.SocketException: Message too long."

IIRC, the effective maximum size of a UDP message (excl. header) is
around 2KB, because some routers might truncate the message.

Is there any guarantee that MINA won't merge or split a message bigger
than this limit into two packet?

It's important for me as my protocol does not use a message terminator
(line feed or some other "special" character) so I'm using
in.array() on ByteBuffer to get the whole content of my datagram.

MINA never manipulate a message by it own.

Also, apparently if the receive buffer size of DatagramSessionConfig is
set lower than the size of the message, the message is truncated.
So it means that if I send 1000 bytes (in one packet) with a receive
buffer of 500 bytes, only 500 bytes will be sent to my protocol decoder
and the remaining 500 bytes will be dropped and not given to my protocol
decoder by another call to decode().

And about the reverse, if I have a receive buffer of 1500 bytes, if I
send 3 packets of 500 bytes, my protocol decoder decode method will be
called three times with an in.array() of 500 bytes?

Exactly.  That's what UDP is.  MINA doesn't change any behavior of UDP.

HTH,
Trustin
Thanks for the confirmation.

Keep up the good work.

Regards,

Bruno

Reply via email to