:-) With block IO, I can do this, but Mina is a NIO framework . If I use Mina , I should use NIO, of course NIO is prominent.
I can use a delimiter to delimit the messages easily . I just want to know what's the reason which lead to this result, so I have this question, Thank all of you. :-) hpq852 2006-07-24 发件人: Maarten Bosteels 发送时间: 2006-07-24 21:40:28 收件人: [email protected] 抄送: 主题: Re: Re: About Mina Question, Could you help me ? On 7/24/06, hpq852 <[EMAIL PROTECTED] > wrote: > > I mainly want to get what is if client flush for 10 times , > then the > server side dataRead method should be invoked 10 times, but I > think it can't > come true. I have followed peter's idea, but it can't resolve the > problem. > > When I don't use NIO just use Socket then it can work well. I > think the > reason is what in socket way the thread was be blocked by > in.readLine() > method, if client have a flush, then the server can read the > data: I am no expert, but I don't believe you can't do this, even with blocking IO: there is no guarantee that 10 calls of flush on the client will lead to 10 invocations of dataRead. Maybe it appears to work on localhost or on your local lan but I would certainly not depend on it. Why do you need this ? Would using a delimiter to delimit your messages not be easier ? Maarten while (true) > { > String str = in.readLine(); > System.out.println(str); > System.out.println("-----------------"); > } > > but in SocketChannel and selector way ,the selector only check if > channel > have data coming. When data come then it will we invoke channel > reading the > data, but in the period of this process, maybe another flush have > be > invoked, then another ' Hello World ' have comed. So the dataRead > moethod > may print the combined string. Is this right ? How should I do > if I want to > get what I want ? Thank you . > > > hpq852 > 2006-07-24 > > > >
