satish viswanatham wrote:
> Hi,
>
> Here is the scenario that I am running into. I am running a TCP server,
> which should be receive messages of size upto 2k in one chunk.
>
> I do the following  config that is used in acceptor bind:
>
>         SocketAcceptorConfig cfg = new SocketAcceptorConfig();
>         cfg.getSessionConfig().setReceiveBufferSize(2048);
>
> I am also doing the following in the message handler:
>
>     public void sessionCreated(IoSession session) throws Exception {
>         log.info("Session created..." + session.getRemoteAddress());
>
>         if( session.getTransportType() == TransportType.SOCKET )
>             ((SocketSessionConfig) session.getConfig()
> ).setReceiveBufferSize( 2048 );
>
> I tried sending 1064 bytes and expected to be received in one message. But I
> received in 2 steps. Notice that HeapBuffer[pos=0 lim=1024 cap=1024 and the
> second time it used HeapBuffer[pos=0 lim=40 cap=2048.
>
> I am using MINA version 1.1.0. Any thoughts? comments? I am using the APIs
> in the wrong way?
>   
I don't think that setting receiveBufferSize (SO_RCVBUF) guarantees that
the data won't be fragmented. You should consider implementing a decoder
for your protocol to be on the safe side:

http://mina.apache.org/tutorial-on-protocolcodecfilter.html

Also, MINA 1.1.3 has been released a couple of days ago. You should
consider upgrading.

HTH

-- 
Niklas Therning
www.spamdrain.net

Reply via email to