0
我試圖創建接收使用NioUdtMessageConnectorChannel作爲通道UDP消息的服務器。粘貼代碼服務器Netty中4.0.15,java.nio.channels.IllegalSelectorException例外
EventLoopGroup group = new NioEventLoopGroup(50,
Executors.defaultThreadFactory());
try {
Bootstrap b = new Bootstrap();
b.group(group);
b.channel(NioUdtMessageConnectorChannel.class);
b.option(UdtChannelOption.SO_BROADCAST, true);
b.option(UdtChannelOption.WRITE_BUFFER_HIGH_WATER_MARK, 1024);
b.option(UdtChannelOption.PROTOCOL_RECEIVE_BUFFER_SIZE, 1024);
b.option(UdtChannelOption.PROTOCOL_SEND_BUFFER_SIZE, 1024);
b.option(UdtChannelOption.TCP_NODELAY, true);
b.option(UdtChannelOption.SO_RCVBUF, 256 * 1024);
b.handler(new SNMPTrapHandler());
b.bind(PORT).sync().channel().closeFuture().await();
} finally {
group.shutdownGracefully();
}
不過,我得到以下錯誤
log4j:WARN Please initialize the log4j system properly.
java.nio.channels.IllegalSelectorException
at sun.nio.ch.SelectorImpl.register(Unknown Source)
at java.nio.channels.spi.AbstractSelectableChannel.register(Unknown Source)
at io.netty.channel.nio.AbstractNioChannel.doRegister(AbstractNioChannel.java:308)
at io.netty.channel.AbstractChannel$AbstractUnsafe.register0(AbstractChannel.java:439)
at io.netty.channel.AbstractChannel$AbstractUnsafe.access$100(AbstractChannel.java:374)
at io.netty.channel.AbstractChannel$AbstractUnsafe$1.run(AbstractChannel.java:418)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:354)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:353)
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:101)
at java.lang.Thread.run(Unknown Source)
什麼是確切的錯誤?
感謝您的答覆,我就想通了,正要在線程中答覆。 –