dev@grizzly.java.net

Re: how to implement closing socket object related to SocketChannel after a period of time is expired

From: Oleksiy Stashok <Oleksiy.Stashok_at_Sun.COM>
Date: Mon, 04 Jan 2010 11:02:55 +0100

Hi,

> IIRC, I think what you are looking for is:
> com
> .sun
> .grizzly
> .nio.transport.TCPNIOConnectorHandler.setConnectionTimeout(int
> timeout)
this value sets timeout for connect operation :)

in 2.0 we don't have expiration mechanism embedded. There is a sample
how expiration could be supported by adding additional Filter
(com.sun.grizzly.utils.IdleTimeoutFilter) in case, if we use a
FilterChain.
For standalone case there is nothing you can use just now.

IMO, in order to support expiration feature fully, we need to create
lastIOTimestamp field on a Connection (AbstractConnection), then
intercept Connection's read/write operations and update
lastIOTimestamp each time. And corresponding Transport implementation
should check all its Connections to detect expired ones. This
implementation will be more complex than in Grizzly 1.9.x, but in
1.9.x we updated expiration timestamp only on "read" operation, so
channel will expire, even if it was actively used for writing.

IOEvent.IDLE is also a good idea! When Transport detects expired
channel it could send IOEvent.IDLE event, and Processor might decide
if it wants to close connection or do something else.

Ming Qin, what do you think? If you have any question or concern -
please let me know. Will appreciate your help with this feature
implementation.

Thanks.

WBR,
Alexey.


>
> charlie ...
>
> ming qin wrote:
>>
>> Hi:
>> For Grizzly 2.0, how to implement closing socket object related to
>> SocketChannel after a period of time is expired , but one
>> endpoint of socket doesn’t receive any data from the other endpoint
>> of socket?
>>
>>
>> Here is a scenario:
>>
>> Server: service Ready
>> Client: greeting service
>> Server: confirming service back
>> Client: ( no data being send over ……) waiting……
>> Server: (After 5 seconds, server closes the socket, since waiting
>> time period is expired) closing socket ……
>>
>>
>> Mina has this implementation on this scenario, I was wondering how
>> to implement same feature on Grizzly 2.0. It seems to me that
>> Processor is the right place to start …….
>>
>>
>> Ming Qin
>> Cell Phone 858-353-2839
>
> --------------------------------------------------------------------- To
> unsubscribe, e-mail: dev-unsubscribe_at_grizzly.dev.java.net For
> additional commands, e-mail: dev-help_at_grizzly.dev.java.net