private AsyncFuture<ProtocolConnection> connectTCP( Logger log, Protocol protocol, ProtocolClient client, RetryPolicy policy ) { final Bootstrap b = new Bootstrap(); b.group(worker); b.channel(NioSocketChannel.class); b.handler(client.initializer()); b.option(ChannelOption.SO_KEEPALIVE, true); final String host = protocol.getAddress().getHostString(); final int port = protocol.getAddress().getPort(); final ProtocolConnection connection = new RetryingProtocolConnection(async, timer, log, policy, new ProtocolChannelSetup() { @Override public ChannelFuture setup() { return b.connect(host, port); } @Override public String toString() { return String.format("connect tcp://%s:%d", host, port); } }); return async.resolved(connection); }