On Tue, Dec 15, 2009 at 11:01 PM, Caldarale, Charles R
<chuck.caldar...@unisys.com> wrote:
>> From: André Warnier [mailto:a...@ice-sa.com]
>> Subject: Re: [OT - question] Limit user sessions in tomcat
>>
>> It would seem that there ought to be some low-level response-direction
>> socket flag that should be available, to tell whether the receiving end
>> has gone, without actually having to send anything from a higher-level
>> code module.  But getting to that low-level socket data does not seem
>> to be so easy in Java, is it ?
>
> It's not hard in Java (Socket.getRemoteSocketAddress() or 
> Socket.isConnected() should work), but there's nothing in the servlet spec 
> that allows a servlet thread to obtain for that information.  Ideally, the 
> container (Tomcat) would asynchronously monitor the socket status and set 
> some flag in the Request object for the webapp code to examine at its 
> leisure.  Might also be able to implement this with a new form of listener.
>
> I haven't looked at the Servlet 3 spec to see if anything is in there for 
> this rather common problem.

Hmm, last time I implemented a tcp/ip stack (which is more than 10
years ago) there were no possibility in the tcp protocol to detect a
broken (not closed) connection except via so_timeout which should be
large enough for a webapp to reply. As far as I know,
socket.isConnected will never return false, once connected, even if
you close the Socket on your side, isConnected will still return true.

As for the OPs question (and i apologize if the answer was already
given) the common approach to prevent f5-hitting users on long-running
requests is to start a background thread which processes the request
(or, more modern, use a Future and the Executor facilities) and return
the current request back to the user with a waiting page, which
refreshes itself in short periods checking whether the background task
is yet finished and redirecting to the result page when done.

regards
Leon

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to