Skip to content

Instantly share code, notes, and snippets.

@paiv
Created April 24, 2015 12:49
Show Gist options
  • Save paiv/9c7b8629fbf686deb9d7 to your computer and use it in GitHub Desktop.
Save paiv/9c7b8629fbf686deb9d7 to your computer and use it in GitHub Desktop.
Netty 4.1: Async connect and DNS name resolving
val boot = new Bootstrap()
.group(new NioEventLoopGroup())
.channel(classOf[NioSocketChannel])
.resolver(new DnsNameResolverGroup(classOf[NioDatagramChannel], DnsServerAddresses.defaultAddresses()))
.option(ChannelOption.TCP_NODELAY, java.lang.Boolean.TRUE)
val channelFuture = boot.connect(host, port)
channelFuture.addListener(new ChannelFutureListener {
override def operationComplete(future: ChannelFuture): Unit =
{
if (future.isSuccess)
// ...
else
future.channel().close()
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment