List threadsBefore = getThreadNames();
final IoAcceptor acceptor = new NioSocketAcceptor();
acceptor.getFilterChain().addLast( "logger", new LoggingFilter() );
acceptor.getFilterChain().addLast( "codec", new ProtocolCodecFilter( new TextLineCodecFactory( Charset.forName( "UTF-8" ))));
acceptor.setHandler( new ServerHandler() );
acceptor.getSessionConfig().setReadBufferSize( 2048 );
acceptor.getSessionConfig().setIdleTime( IdleStatus.BOTH_IDLE, 10 );
acceptor.bind( new InetSocketAddress(PORT) );
System.out.println("Server running ...");
final NioSocketConnector connector = new NioSocketConnector();
// Set connect timeout.
connector.setConnectTimeoutMillis(30 * 1000L);
connector.setHandler(new ClientHandler());
connector.getFilterChain().addLast( "logger", new LoggingFilter() );
connector.getFilterChain().addLast( "codec", new ProtocolCodecFilter( new TextLineCodecFactory( Charset.forName( "UTF-8" ))));
// Start communication.
ConnectFuture cf = connector.connect(new InetSocketAddress("localhost", 9123));
cf.awaitUninterruptibly();