Emmanuel Lécharny <elecharny@...> writes:
>
> Le 8/20/12 3:28 PM, Harakiri a écrit :
> >
> > --- On Mon, 8/20/12, Emmanuel Lécharny <elecharny@...> wrote:
> >
> >> From: Emmanuel Lécharny <elecharny@...>
> >> Subject: Re: Forcing the closure of any open session when mina server
shuts down
> >> To: users@...
> >> Date: Monday, August 20, 2012, 8:54 AM
> >> Le 8/20/12 2:41 PM, Harakiri a écrit
> >> :
> >>> Hello,
> >>>
> >>> thanks for your input - i tried it with both
> >> close(true) and close(false) - but i would expect that
> >> close(false) blocks till all sessions are really closed -
> >> however the doc states something about flushing pending
> >> writes - i dont think there are any pending writes when the
> >> connection is just idle.
> >>
> >> You can also call the servise.dispose( boolean ) method. If
> >> the parameter is 'true', the service will try to flush all
> >> the pending writes. Otherwise, it will immediately close all
> >> the sessions.
> > I think most of my issues result in the rebinding of the port - in java
there is setReuseAddress(boolean on)
> // Enable/disable the SO_REUSEADDR socket option for a serversockt
- is there something similar for mina?
> >
> > I found in the archive your post about
> >
> > acceptor.getSessionConfig().setReuseAddress
> >
> > but that does not exist in 2.x
>
> Of course it does !
>
> public class DefaultSocketSessionConfig extends
> AbstractSocketSessionConfig {
> ...
> public void setReuseAddress(boolean reuseAddress) {
> this.reuseAddress = reuseAddress;
> }
>
> The thing is that you have to cast the acceptor.getSessionConfig() to be
> able to set the flag, because it implements an interface which is a bit
> generic (IoSessionConfig) :
>
> ((SocketSessionConfig)acceptor.getSessionConfig() ).setReuseAddress( true
);
>
> Or you can set it for the whole service :
>
> SocketAcceptor acceptor = new NioSocketAcceptor();
> acceptor.setReuseAddress( true );
>
> >
> >
>
I have Implemented following code
SocketAcceptor acceptor = new NioSocketAcceptor();
acceptor.setReuseAddress( true );
though it throws
java.net.BindException: Address already in use Exception Also tried with
following code
NioSocketAcceptor acceptor = new NioSocketAcceptor()
acceptor.getSessonConfig().setReuseAddress(true);
It also doesn't work