Le 11/8/13 5:25 AM, Jack a écrit :
> I want to know immediately when MINA disconnected from client, But I have no
> way.

because there is no way, unless the disconnection is clean.

> If MINA disconnected from client, generally as we know sesseionClose() in
> IoHandlerAdapter be not called immediately. It needs few seconds.(about
> 15~20)
That's not true. If the client correctly close the connection, then the
sessionClose() event *will* be called immediately.

Although if the client just unplug the cable, without explicitely
closing the connection, then you'll get informed when the timeout is
reached.
This is the very nature of TCP, there is nothing you can do about it but
checking for the session iddleness.
>
> That's whay I need to know result of IoSession.write() wheather successful
> or not.
The only thing you can do is to check the messageSent() event, which
will be fired as soon as your message has been fully written in the
socket (which does not mean your client has received it, or that the
client is even connected).

> Ofcourse we have write(object).isWrittend() or .isDone() in IoFutureListener
> or something like that.
> Even though client has disconnect, it always return "true" before MINA
> recognize disconnection from client.

Because we don't have any way to know if the client has disconnected.

> So I can't trust in that.

Check the iddleness.

>
> How to know state of disconnection immediately? 

You can't.

> or packet delivered to
> client successfully?

You can't. The only way would be for your client to send an Ack.
>
> PS. I will not use Handshaking module likes keepalive or ping-pong.

Then you are on your own. Like it or not, this is how TCP works.


-- 
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com 

Reply via email to