NIO的陷阱(一)

SocketChannel.open(new InetSocketAddress(hostIp, hostListenningPort))与SocketChannel.open(),socketChannel.connect(new InetSocketAddress(hostIp, hostListenningPort))的比较


相同点:这两种写法实现的功能一样,都是打开通道并连上服务端

不同点:前一种不能监听到socketChannel.register(selector,SelectionKey.OP_CONNECT)事件

 

 

 

你可能感兴趣的:(nio,SocketChannel)