mina-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Cameron Taggart" <cameron.tagg...@gmail.com>
Subject Re: Problem of SocketConnector
Date Tue, 14 Nov 2006 17:59:17 GMT
Added to FAQ.
http://cwiki.apache.org/confluence/display/MINA/FAQ#FAQ-WhydoesSocketConnectorsendseveralmessagesasonemessage%3F

cheers,
Cameron

On 11/14/06, Trustin Lee <trustin@gmail.com> wrote:
> We'd better add this answer to our FAQ page.  IIRC, we got this same
> question more than ten times. :D
>
> Trustin
>
> On 11/14/06, Niklas Therning <niklas@trillian.se> wrote:
> >
> > tan wenlong wrote:
> > > Hi,When I use the SocketConnector send messages to Server, Sometime It
> > will send several messages as one message. For example, I hope that
> > SocketConnector send "abc" and "def", but SocketConnector send "abcdef". Is
> > it a bug of mina?
> > >
> > >
> > No, this is due to your OS trying to send packets more efficiently (see
> > http://en.wikipedia.org/wiki/Nagle_algorithm). You can enable/disable
> > Nagle's algorithm by a call to SocketSessionConfig.setTcpNoDelay(), e.g.:
> >
> > ((SocketSessionConfig) connector.getSessionConfig()).setTcpNoDelay(false)
> >
> > However, even if you do this you cannot expect one session.write(bytes)
> > in MINA to correspond to one TCP packet on your network. You should
> > probably implement your own MINA ProtocolDecoder to handle the assembly
> > of incoming bytes into message objects. The TextLineCodec is a good
> > start if the protocol you're implementing is based on text lines. For a
> > more advanced example have a look at the SumUp example in the MINA
> > distribution.
> >
> > HTH
> >
> > --
> > Niklas Therning
> > www.spamdrain.net
> >
> >
>
>
> --
> what we call human nature is actually human habit
> --
> http://gleamynode.net/
> --
> PGP key fingerprints:
> * E167 E6AF E73A CBCE EE41  4A29 544D DE48 FE95 4E7E
> * B693 628E 6047 4F8F CFA4  455E 1C62 A7DC 0255 ECA6
>
>

Mime
View raw message