You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by hpq852 <hp...@gmail.com> on 2006/07/22 11:58:49 UTC
About Mina Question, Could you help me ?
Hello Everyone, I'm using Mina for a TCP Server, but I suffer from a question which I can't resolve it and I beg your help. Thank you very much and the question is as following :
Client side : I have 10 threads and the run method is :
public void run()
{
for(int i=0; i<1; i++)
{
out.print(" Hello World ");
out.flush();
}
}
I have flushed after every 'print' operation. In server side I want to get the result as :
Hello World
----------------
Hello World
----------------
Hello World
----------------
Hello World
----------------
Hello World
----------------
Hello World
----------------
......
but the result which I get is :
Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World
-----------------------
The code in server side is :
public synchronized void dataRead(IoSession session, ByteBuffer rb) throws Exception
{
byte[] datas = new byte[rb.remaining()];
rb.get(datas);
String commandStr = new String(datas);
logger.info(commandStr);
logger.info("----------------------------------");
}
what's the reason ? By the way the mina I'm using is verson 0.8. Thanks a lot . Best wishes!
Re: About Mina Question, Could you help me ?
Posted by John Preston <by...@gmail.com>.
Shouldn't you use out.println(" Hello World ");
John
On 7/22/06, hpq852 <hp...@gmail.com> wrote:
> Hello Everyone, I'm using Mina for a TCP Server, but I suffer from a question which I can't resolve it and I beg your help. Thank you very much and the question is as following :
>
> Client side : I have 10 threads and the run method is :
>
> public void run()
> {
> for(int i=0; i<1; i++)
> {
> out.print(" Hello World ");
> out.flush();
> }
> }
>
> I have flushed after every 'print' operation. In server side I want to get the result as :
>
> Hello World
> ----------------
> Hello World
> ----------------
> Hello World
> ----------------
> Hello World
> ----------------
> Hello World
> ----------------
> Hello World
> ----------------
> ......
>
> but the result which I get is :
>
> Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World Hello World
> -----------------------
>
> The code in server side is :
>
> public synchronized void dataRead(IoSession session, ByteBuffer rb) throws Exception
> {
> byte[] datas = new byte[rb.remaining()];
> rb.get(datas);
>
> String commandStr = new String(datas);
> logger.info(commandStr);
> logger.info("----------------------------------");
> }
>
> what's the reason ? By the way the mina I'm using is verson 0.8. Thanks a lot . Best wishes!
>
>