users@grizzly.java.net

Re: detect network disconnected?

From: Oleksiy Stashok <Oleksiy.Stashok_at_Sun.COM>
Date: Wed, 23 Dec 2009 10:41:16 +0100

Hi,

> IIRC, if a read attempt is done on channel that has its network
> cable unplugged should result in some kind of an IOException being
> thrown even if there is no data readily available on the channel.
>
> So, some kind of "heart beat" mechanism that does a periodic read()
> of a channel should detect a disconnected network cable.
>
> Perhaps a simple program would prove / disprove this?
Agree. From what I know, if connection was closed read() operation
will return either -1 or throw IOException (depending on OS and JDK).
Unfortunately it's also true, that write operation may succeed on
connection, which was closed by peer.

Also agree, that "Heart beat" mechanism could be a good solution.

WBR,
Alexey.

>
> charlie ...
>
> ichinco wrote:
>> Not quite. We have implemented this, but it does not close the
>> channel if the
>> network cable is unplugged. (neither remotlyclosed nor locallyclosed
>> functions get called.)
>>
>> I'm most surprised that you can still write (without an exception!)
>> to a
>> channel whose client is no longer connected to the network.
>>
>>
>> survivant wrote:
>>
>>> can this blog help you ?
>>>
>>> http://weblogs.java.net/blog/2008/11/25/grizzly-how-be-notify-when-client-disconnect
>>>
>>>
>>>
>>> 2009/12/22 ichinco <ichinco_at_gmail.com>
>>>
>>>
>>>> Hello, all,
>>>>
>>>> Is there a way to tell on the server-side whether a client has lost
>>>> network
>>>> connection (ie, network cable pulled)?
>>>>
>>>> The channel doesn't get closed automatically,
>>>> SelectionKey.channel().isOpen() reports true, and if I try to
>>>> write to it
>>>> (OutputWriter.flushChannel), there is no IOError. Is there a fool-
>>>> proof
>>>> way
>>>> to tell whether the channel is still open from the server side?
>>>>
>>>> Thanks!
>>>> --
>>>> View this message in context:
>>>> http://old.nabble.com/detect-network-disconnected--tp26891745p26891745.html
>>>> Sent from the Grizzly - Users mailing list archive at Nabble.com.
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
>>>> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>>>>
>>>>
>>>>
>>> --
>>> -------------
>>> A+
>>>
>>> Sébastien.
>>>
>>> Vous pouvez me suivre sur Twitter / You can follow me on Twitter :
>>> http://twitter.com/survivant
>>>
>>>
>>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>