// Set connect timeout.
connector.setConnectTimeoutMillis(30*1000L);
// Start communication.
connector.setHandler(new NetCatProtocolHandler());
ConnectFuture cf = connector.connect(
new InetSocketAddress(args[0], Integer.parseInt(args[1])));
// Wait for the connection attempt to be finished.
cf.awaitUninterruptibly();
cf.getSession().getCloseFuture().awaitUninterruptibly();