Created
May 17, 2016 16:03
-
-
Save Jire/5f3b5146aa10dd28a2c341a0f57dc8d6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 group = NioEventLoopGroup() | |
val initializer = object : ChannelInitializer<SocketChannel>() { | |
override fun initChannel(ch: SocketChannel) { | |
ch.pipeline().addFirst(object : ChannelInboundHandlerAdapter() { | |
override fun channelRegistered(ctx: ChannelHandlerContext) { | |
ctx.writeAndFlush(buf) | |
println("Sent.") | |
} | |
}) | |
} | |
} | |
for (i in 1..1) { | |
with(Bootstrap()) { | |
group(group) | |
channel(NioSocketChannel::class.java) | |
option(ChannelOption.SO_KEEPALIVE, true) | |
handler(initializer) | |
connect(addr) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment