I've been using Netty 4.0.8 and it works great for binding to multiple TCP ports but I was wondering if the same binding approach can be used for a UDP server.
Each time this runs it only seems to be able to bind on the first attempt and chokes on the second.
Binding to port 80
Binding to port 81
Exception in thread "main" java.lang.IllegalStateException: channel not registered to an event loop
at io.netty.channel.AbstractChannel.eventLoop(AbstractChannel.java:106)
at io.netty.channel.nio.AbstractNioChannel.eventLoop(AbstractNioChannel.java:102)
at io.netty.channel.nio.AbstractNioChannel.eventLoop(AbstractNioChannel.java:41)
at io.netty.bootstrap.AbstractBootstrap.doBind0(AbstractBootstrap.java:317)
at io.netty.bootstrap.AbstractBootstrap.doBind(AbstractBootstrap.java:264)
at io.netty.bootstrap.AbstractBootstrap.bind(AbstractBootstrap.java:256)
at io.netty.bootstrap.AbstractBootstrap.bind(AbstractBootstrap.java:231)
at UDPServer.run(UDPServer.java:67)
at UDPServer.main(UDPServer.java:87)
04-Sep-2013 15:56:21 io.netty.util.concurrent.DefaultPromise notifyListener0
WARNING: An exception was thrown by UDPServer$1.operationComplete()
java.lang.ClassCastException: io.netty.channel.AbstractChannel$CloseFuture cannot be cast to io.netty.channel.group.ChannelGroupFuture
at UDPServer$1.operationComplete(UDPServer.java:47)
at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:621)
at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:548)
at io.netty.util.concurrent.DefaultPromise.trySuccess(DefaultPromise.java:389)
at io.netty.channel.DefaultChannelPromise.trySuccess(DefaultChannelPromise.java:82)
at io.netty.channel.AbstractChannel$CloseFuture.setClosed(AbstractChannel.java:821)
at io.netty.channel.AbstractChannel$AbstractUnsafe.close(AbstractChannel.java:541)
at io.netty.channel.nio.NioEventLoop.closeAll(NioEventLoop.java:543)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:351)
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:101)
at java.lang.Thread.run(Thread.java:662)
Java Result: 1