FrameDecoder

Trustin Lee (이희승) trustin at gmail.com
Tue Sep 29 04:53:15 EDT 2009


On Fri, Sep 25, 2009 at 5:52 PM, sohguanh <sohguanh at yahoo.com.sg> wrote:
>
> Not wanting to flood the forum I tag along my existing topic.

The best way not to flood the forum is to read the user guide first.
I hope you did.

> TelnetClient.java Feature ?
>
> I refer to the online sample code TelnetClient.java line 92
>
> lastWriteFuture = channel.write(line + '\n');
>
> Above will throw ClassCastException. Tracing through the Netty code reveal
> an attempt to cast to ChannelBuffer will give a "can not fail" error.
>
> I tweak above to below and all works fine.
>
> lastWriteFuture = channel.write(ChannelBuffers.copiedBuffer(line + '\n',
> "UTF-8");
>
> It seems Netty is using ChannelBuffer which extends java.lang.Object to
> read/write bytes to nio.
>
> Just want to share if anyone has the same problem as me.

There is a StringEncoder in the pipeline of the TelnetClient example,
and that's why writing a String works without a ClassCastException.

— Trustin Lee, http://gleamynode.net/



More information about the netty-users mailing list