You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by tunkul <tu...@gmail.com> on 2007/09/09 21:34:14 UTC

sending null-terminated strings

Hi, i'd like to set up a server which accepts newline terminated strings as
the "messages" (ie, pretty much what TestLineCodecFactory does), but when i
send messages on these sessions i want to terminate them with a null
character, not the newline char.

What's the best way to accomplish this?

Thanks.
-- 
View this message in context: http://www.nabble.com/sending-null-terminated-strings-tf4410525s16868.html#a12582206
Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.


Re: sending null-terminated strings

Posted by Trustin Lee <tr...@gmail.com>.
On 9/11/07, tunkul <tu...@gmail.com> wrote:
>
> This is precisely what i did after looking at some source. It would've been
> nice if you could configure a TextLineCodecFactory with one's own
> TextLineEncoder/Decoder instead of having them hard-coded in the ctor.

You can do that in MINA-2.0.0-M1-SNAPSHOT.  It's not released yet, but
will be released sooner or later. :)

Trustin
-- 
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6

Re: sending null-terminated strings

Posted by tunkul <tu...@gmail.com>.
This is precisely what i did after looking at some source. It would've been
nice if you could configure a TextLineCodecFactory with one's own
TextLineEncoder/Decoder instead of having them hard-coded in the ctor.


Trustin Lee wrote:
> 
> On 9/10/07, tunkul <tu...@gmail.com> wrote:
>>
>> Hi, i'd like to set up a server which accepts newline terminated strings
>> as
>> the "messages" (ie, pretty much what TestLineCodecFactory does), but when
>> i
>> send messages on these sessions i want to terminate them with a null
>> character, not the newline char.
>>
>> What's the best way to accomplish this?
> 
> You could create a new ProtocolCodecFactory with two existing classes;
> TextLineEncoder and TextLineDecoder.  Please specify a custom
> LineDelimiter for the two (i.e. new LineDelimiter("\0")).
> 
> Please refer to the source code of TextLineCodecFactory.  You could
> simply modify the constructor invocation part.
> 
> HTH,
> Trustin
> -- 
> what we call human nature is actually human habit
> --
> http://gleamynode.net/
> --
> PGP Key ID: 0x0255ECA6
> 
> 

-- 
View this message in context: http://www.nabble.com/sending-null-terminated-strings-tf4410525s16868.html#a12599336
Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.


Re: sending null-terminated strings

Posted by Trustin Lee <tr...@gmail.com>.
On 9/10/07, tunkul <tu...@gmail.com> wrote:
>
> Hi, i'd like to set up a server which accepts newline terminated strings as
> the "messages" (ie, pretty much what TestLineCodecFactory does), but when i
> send messages on these sessions i want to terminate them with a null
> character, not the newline char.
>
> What's the best way to accomplish this?

You could create a new ProtocolCodecFactory with two existing classes;
TextLineEncoder and TextLineDecoder.  Please specify a custom
LineDelimiter for the two (i.e. new LineDelimiter("\0")).

Please refer to the source code of TextLineCodecFactory.  You could
simply modify the constructor invocation part.

HTH,
Trustin
-- 
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6