You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by Celio Cidral <ce...@kidux.net> on 2009/01/09 14:12:09 UTC

IoAcceptor does not unbind address 0.0.0.0

I'm not sure whether this is an issue or not.  We have experienced that the
NioSocketAcceptor does not unbind the 0.0.0.0 address.  When you
bind(0.0.0.0), the NioSocketAcceptor gets a SocketAddress from the
ServerSocketChannel containing a slightly different address:

NioSocketAcceptor.java:
    protected SocketAddress localAddress(ServerSocketChannel handle)
            throws Exception {
        return handle.socket().getLocalSocketAddress();
    }


The address returned by handle.socket().getLocalSocketAddress() is
"0.0.0.0.0.0.0.0/<port>".  Then the acceptor keeps that address and when you
try to unbind() "0.0.0.0/<port>", it does not find the address and does not
unbind it.  Our workaround is to call unbind() without any parameters, so
that it effectivelly unbind all local addresses.

I've attached a patch (against MINA-2.0 M4) containing a unit test for this
use case.

Best regards,

CĂ©lio