Created
April 24, 2015 12:49
-
-
Save paiv/9c7b8629fbf686deb9d7 to your computer and use it in GitHub Desktop.
Netty 4.1: Async connect and DNS name resolving
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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