On 8/23/07, Matthew Phillips <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> this is related to the discussion quoted below which lead to
> DIRMINA-382.
>
> I'm basically still not sure how to cleanly close down a set of
> connections when the protocol involves sending a "disconnect" style
> message before closing the socket.
>
> After putting the disconnect messages into the queue for each
> session, I'm doing the following:
>
> SocketAcceptor socketAcceptor = ...
> Set<InetSocketAddress> addresses = ...
>
> for (InetSocketAddress address : addresses)
> {
> for (IoSession session : socketAcceptor.getManagedSessions
> (address))
> session.close ().join (10000);
>
> socketAcceptor.unbind (address);
> }
>
> // when I get here I want to be sure we're fully closed down
>
> I'm not sure that (a) this works and (b) whether it's overkill and
> unbind () might be doing this. Can someone clarify the semantics, and
> perhaps we can get some documentation? I'd be happy to write some
> myself once I understand what's going on :)
If you are going to close all connections immediately on unbind
without sending any notification message to remote peers, just calling
unbind() will be enough. IoAcceptorConfig has a property called
'disconnectOnUnbind', whose default value is 'true'. If it's set to
true, all connections are automatically closed on unbind.
HTH,
Trustin
--
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6