How to reliable and efficiently implement a string protocol

ljohnston johnstlr at yahoo.co.uk
Wed Nov 3 14:42:16 EDT 2010


Assuming your messages only go from client to server then your client needs a
StringEncoder and the server needs to combine DelimiterBasedFrameDecoder and
StringDecoder. For example

client

...addLast("encoder", new StringEncoder(CharsetUtil.UTF_8));

server

...addLast("delimiter", new DelimiterBasedFrameDecoder(65535,
Delimiters.lineDelimiter());
...addLast("decoder", new StringDecoder(CharsetUtil.UTF_8));

By default the DelimiterBasedFrameDecoder will strip the line delimiters
from the message. There are alternative constructors which allow you specify
whether the delimiters should be stripped or not.

Cheers
Lee
-- 
View this message in context: http://netty-forums-and-mailing-lists.685743.n2.nabble.com/How-to-reliable-and-efficiently-implement-a-string-protocol-tp5697794p5702731.html
Sent from the Netty User Group mailing list archive at Nabble.com.


More information about the netty-users mailing list