62,628
社区成员
发帖
与我相关
我的任务
分享
Selector selector = Selector.open();
ServerSocketChannel channel = ServerSocketChannel.open();
channel.configureBlocking(false); //讲通道设置为非阻塞
channel.socket().bind(new InetSocketAddress(PORT)); //绑定端口
channel.register(this.selector, SelectionKey.OP_ACCEPT); //为通道注册OP_ACCEPT事件