Thanks, that works like a dream. On Tue, Jul 14, 2009 at 7:35 PM, Chowdhury, Shubhankar [WHQKA] < [email protected]> wrote:
> Did you try setting the "reuseAddress" property on acceptor to true? > That solved my problem in Linux. > > Thanks, > Shubhankar > 847-700-4452 > > -----Original Message----- > From: Meeraj Kunnumpurath [mailto:[email protected]] > Sent: Tuesday, July 14, 2009 1:16 PM > To: [email protected] > Subject: NIOSocketAcceptor unbind and dispose > > Hi, > > I have a server written using Mina with the NIO socket acceptor. When I > shutdown the server I call unbind and dispose on the acceptor as > follows, > > @Destroy > public void stop() throws InterruptedException { > for (IoSession session : acceptor.getManagedSessions().values()) > { > session.close(false).await(); > } > acceptor.unbind(); > acceptor.dispose(); > } > > However, on OSX if I immediately try to restart the server, it throws a > bind > exception stating address is already in use. On Solaris, I am unable to > restart the server at all without bouncing the box. Below is the code I > use > to start the server, > > @Init > public void start() throws IOException { > ExecutorService filterExecutor = new > SCA4JExecutorService(workScheduler); > InetSocketAddress socketAddress; > if (listenAddress == null) { > socketAddress = new > InetSocketAddress(InetAddress.getLocalHost(), commandPort); > } else { > socketAddress = new InetSocketAddress(listenAddress, > commandPort); > } > acceptor = new NioSocketAcceptor(); > SocketSessionConfig config = acceptor.getSessionConfig(); > config.setIdleTime(IdleStatus.READER_IDLE, idleTimeout); > acceptor.getFilterChain().addLast("threadPool", new > ExecutorFilter(filterExecutor)); > acceptor.getFilterChain().addLast("codec", new > ProtocolCodecFilter(codecFactory)); > acceptor.setHandler(ftpHandler); > monitor.extensionStarted(); > acceptor.setCloseOnDeactivation(true); > acceptor.bind(socketAddress); > monitor.startFtpListener(commandPort); > } > > Any pointers would be highly useful. > > Kind regards > Meeraj > > > >
