public void start() throws Exception { acceptor = new SocketAcceptor(); // Prepare the configuration SocketAcceptorConfig cfg = new SocketAcceptorConfig(); cfg.setReuseAddress(true); Charset charset = Charset.forName("UTF-8"); cfg.getFilterChain() .addLast("codec", new ProtocolCodecFilter(new TextLineCodecFactory(charset))); // Bind acceptor.bind(new InetSocketAddress(port), new ReverseProtocolHandler(), cfg); }
public void stop() throws Exception { acceptor.unbindAll(); }