ChannelBuffer and messageReceived
manish_iitg
excellencetechnologies08 at gmail.com
Fri Dec 26 22:31:27 EST 2008
Take a look at this.
http://www.jboss.org/file-access/default/members/netty/freezone/api/3.0/org/jboss/netty/handler/codec/frame/FrameDecoder.html
This will solve all your problem.
nixter wrote:
>
> Hello,
>
> I have a writed a client/server program.
>
> The client send data assembled in ChannelBuffer, the data look like this :
>
> Sender, receiver, tag, DATA
>
> Where sender, receiver, tag are integer and datas are a set of bytes.
>
> the client send data like this :
>
> channel.write(ChannelBuffers.wrappedBuffer(buffer)); where buffer is a
> BufferByte.
>
> In server side, to gather datas I do like this :
>
> public synchronized void messageReceived(ChannelHandlerContext ctx,
> MessageEvent e) {
>
> ByteBuffer buff = null;
>
> ChannelBuffer chanbuf = (ChannelBuffer) e.getMessage();
>
> buff=chanbuf.toByteBuffer();
>
> int src=buff.getInt();
> int dest=buff.getInt();
> int tag=buff.getInt();
>
> ...
> }
>
> The problème is for small buffer i got the correct data, but for some
> buffer i receive wrong data!! I know because communication are
> non-bloquant.
>
> My question is : when netty call messageReceived () is the ChannelBuffer
> contains the whole data?
> is there a mecansime like ByteBuffer.hasremaining to read the whole data
> sent?
>
> Please help if you have an idea or an example.
>
> P.S sorry for my English
>
> ---- Here some log :
>
> the client send one message (header+data), and i noticed that
> messageReceived () is invoked 5 time!!
>
>
>
> (message: BigEndianHeapChannelBuffer(ridx=0, widx=1536, cap=1536))
> (message: BigEndianHeapChannelBuffer(ridx=0, widx=2048, cap=2048))
> (message: BigEndianHeapChannelBuffer(ridx=0, widx=3072, cap=3072))
> (message: BigEndianHeapChannelBuffer(ridx=0, widx=4096, cap=4096))
> (message: BigEndianHeapChannelBuffer(ridx=0, widx=4657, cap=6144)
>
>
>
--
View this message in context: http://n2.nabble.com/ChannelBuffer-and---messageReceived-tp1943393p1972251.html
Sent from the Netty User Group mailing list archive at Nabble.com.
More information about the netty-users
mailing list