hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: Differentiating Connection Timeouts and Closes
Date Sun, 15 Jan 2012 21:11:14 GMT
On Mon, 2012-01-16 at 01:21 +0530, Asankha C. Perera wrote:
> Hi All
> When a connection times out or is closed with NIO, I'd like to know if 
> this connection has any content read already or pending - i.e. is the 
> connection timeout or close happening to a partially read connection or 
> to an idle keep-alive connection (I'd like to know even if some headers 
> have been read.. not just entity content..)
> I was not able to find any safe way to achieve this yet.. Have I missed 
> anything obvious?
> thanks
> asankha

Hi Asankha

Timeout event fired by an I/O reactor simply signals the fact that there
has been no activity on that I/O session for the given timeout period.
The I/O session itself remains in a perfectly valid state. It is up to
individual protocol handlers to decide what is to be done with that
session. The default implementations simply close the timed out session
but it does not have to be that way.

As far as closed I/O sessions are concerned, if closed by the opposite
end, the I/O session can still be read from as long as there is pending
data. Once all input has been received read operations on that session
will start returning -1 indicating the connection is being in a
half-closed state. It is still up to individual protocol handlers to
decide what is to be done with the session. Closing it on the local end
is the most natural choice. 

Both cases are quite easy to distinguish. Hope this answers your



To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org

View raw message