摘要:
异步连接需要做以下操作: 设置socket为非阻塞模式 注册OP_CONNECT事件 OP_CONNECT事件发生时,调用SocketChannel的finishConnection 代码如下: public class Client1 { Selector selector; int writeE 阅读全文
摘要:
首先看代码: public class ByteBufferTry { public static void main(String args[]) { byte[] ba = new byte[10]; Arrays.fill(ba, (byte)0); ByteBuffer bb = ByteB 阅读全文
摘要:
1、NIO的selector是边缘触发还是水平触发? 水平触发,看下面这段代码: public class Client1 { Selector selector; int writeEventTrigerCount = 0; public void run() throws IOException 阅读全文