摘要: 这里以socket文件来阐述它们之间的区别,假设现在服务器端有100 000个连接,即已经创建了100 000个socket。 1 select和poll 在我们的线程中,我们会弄一个死循环,在循环里面不断的进行select()。这个select()进入操作系统层面,会主动去调用每个socket文件 阅读全文
posted @ 2017-12-25 20:55 PhoenixTree(梧桐树) 阅读(244) 评论(0) 推荐(0)
摘要: 1 这两个类是抽象类 源码里面它们的前面是加了abstract的。 2 抽象类是不能new出实例的 3 这两个类使用静态方法open创建其子类的实例 有动态绑定原理可知,返回的ServerSocketChannel和SocketChannel引用指向的是其子类的对象。在调用accept()、conn 阅读全文
posted @ 2017-12-25 16:51 PhoenixTree(梧桐树) 阅读(296) 评论(0) 推荐(0)
摘要: 1 SocketChannel 1.1 打开一个SocketChannel SocketChannel socketChannel = SocketChannel.open(); socketChannel.connect(new InetSocketAddress("http://www.baid 阅读全文
posted @ 2017-12-25 15:55 PhoenixTree(梧桐树) 阅读(238) 评论(0) 推荐(0)