I'm testing EpollServerSocketChannel and found that the port returned by it after binding is always 0. Is this expected? This is with Netty 4.0.17-Final
val bossGroup = new io.netty.channel.epoll.EpollEventLoopGroup(1)
val workerGroup = new io.netty.channel.epoll.EpollEventLoopGroup(0)
val bootstrap = new io.netty.bootstrap.ServerBootstrap
bootstrap.group(bossGroup, workerGroup).channel(classOf[io.netty.channel.epoll.EpollServerSocketChannel]).childHandler(new io.netty.channel.ChannelInitializer[io.netty.channel.socket.SocketChannel] {
override def initChannel(ch: io.netty.channel.socket.SocketChannel): Unit = {
}
})
val cf = bootstrap.bind(new java.net.InetSocketAddress(12345))
cf.sync()
println("local address is " + cf.channel.localAddress)
If I replace Epoll with Nio, the output works:
val bossGroup = new io.netty.channel.nio.NioEventLoopGroup(1)
val workerGroup = new io.netty.channel.nio.NioEventLoopGroup(0)
val bootstrap = new io.netty.bootstrap.ServerBootstrap
bootstrap.group(bossGroup, workerGroup).channel(classOf[io.netty.channel.socket.nio.NioServerSocketChannel]).childHandler(new io.netty.channel.ChannelInitializer[io.netty.channel.socket.SocketChannel] {
override def initChannel(ch: io.netty.channel.socket.SocketChannel): Unit = {
}
})
val cf = bootstrap.bind(new java.net.InetSocketAddress(0))
cf.sync()
println("local address is " + cf.channel.localAddress)
local address is /0:0:0:0:0:0:0:0:44569