You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@mina.apache.org by hezjing <he...@gmail.com> on 2008/10/15 08:15:29 UTC

Calling prefixedDataAvailable with argument other than 1, 2, or 4

Hi
The Javadoc of IoBuffer.prefixedDataAvailable(int prefixLength) explains
that
the argument prefixLength - the length of the prefix field (1, 2, or 4).

Do you know why the argument prefixLength has to be 1, 2 or 4?

I want to decode a UDP message which always contains a 6 bytes header.
Does it causes any problem when calling prefixedDataAvailable(6)?


-- 

Hez

Re: Calling prefixedDataAvailable with argument other than 1, 2, or 4

Posted by Andres Quijano <tu...@gmail.com>.
errata: prefixedDataAvailable doesn't wait for the bytes, just returns
true if they are present, false if they are not

On Wed, Oct 15, 2008 at 9:28 AM, Andres Quijano <tu...@gmail.com> wrote:
> prefixedDataAvailable reads the specified parameter bytes and
> interprets that as a number (which is supposed to be the length of the
> message) then waits until that amount of bytes is available
>
> If you want to decode UDP messages (with this assumed description
> http://www.networksorcery.com/enp/protocol/udp.htm) in your protocol
> you should wait for 6 bytes (source, destination and length) and then
> use prefixedDataAvailable(2) on the buffer, after you skipped the
> first 4 bytes (source and destination)
>
> If you do prefixedDataAvailable(6) (assuming it would work) then MINA
> would read the first 6 bytes, treat that as a number, and wait for
> that amount of bytes to arrive... you can guess it can be a pretty big
> number! (up to 256 terabytes!!)
>
> On Wed, Oct 15, 2008 at 3:15 AM, hezjing <he...@gmail.com> wrote:
>> Hi
>> The Javadoc of IoBuffer.prefixedDataAvailable(int prefixLength) explains
>> that
>> the argument prefixLength - the length of the prefix field (1, 2, or 4).
>>
>> Do you know why the argument prefixLength has to be 1, 2 or 4?
>>
>> I want to decode a UDP message which always contains a 6 bytes header.
>> Does it causes any problem when calling prefixedDataAvailable(6)?
>

Re: Calling prefixedDataAvailable with argument other than 1, 2, or 4

Posted by Andres Quijano <tu...@gmail.com>.
prefixedDataAvailable reads the specified parameter bytes and
interprets that as a number (which is supposed to be the length of the
message) then waits until that amount of bytes is available

If you want to decode UDP messages (with this assumed description
http://www.networksorcery.com/enp/protocol/udp.htm) in your protocol
you should wait for 6 bytes (source, destination and length) and then
use prefixedDataAvailable(2) on the buffer, after you skipped the
first 4 bytes (source and destination)

If you do prefixedDataAvailable(6) (assuming it would work) then MINA
would read the first 6 bytes, treat that as a number, and wait for
that amount of bytes to arrive... you can guess it can be a pretty big
number! (up to 256 terabytes!!)

On Wed, Oct 15, 2008 at 3:15 AM, hezjing <he...@gmail.com> wrote:
> Hi
> The Javadoc of IoBuffer.prefixedDataAvailable(int prefixLength) explains
> that
> the argument prefixLength - the length of the prefix field (1, 2, or 4).
>
> Do you know why the argument prefixLength has to be 1, 2 or 4?
>
> I want to decode a UDP message which always contains a 6 bytes header.
> Does it causes any problem when calling prefixedDataAvailable(6)?