上一页 1 2 3 4 5 6 7 8 ··· 25 下一页
摘要: 阅读全文
posted @ 2022-08-22 22:05 努力的达子 阅读(6) 评论(0) 推荐(0) 编辑
摘要: . 4.接收:SelectionKey.OP_ACCEPT; NIO非阻塞式网络通信的原理分析 服务端样例: /** * Nio非阻塞通信下的入门案例:服务端开发 */ public class Server { public static void main(String[] args) thro 阅读全文
posted @ 2022-08-19 08:27 努力的达子 阅读(59) 评论(0) 推荐(0) 编辑
摘要: public interface Channel extend Clonseable{} . 写案例: @Test public void write() { try { //1.字节输出流到目标文件 FileOutputStream fos = new FileOutputStream("data 阅读全文
posted @ 2022-08-18 19:44 努力的达子 阅读(159) 评论(0) 推荐(0) 编辑
摘要: static xxxBuffer allocate(int capacity):创建一个容量为capacity 的xxxBuffer对象 样例: @Test public void test01() { //1.分配一个缓冲区,容量设置为10 ByteBuffer buffer = ByteBuff 阅读全文
posted @ 2022-08-16 20:22 努力的达子 阅读(87) 评论(0) 推荐(0) 编辑
摘要: 1.简介 2.NIO和BIO的比较 1.BIO以流的方式处理数据,而NIO以块的放还是处理数据,块的I/O都效率比流的I/O高很多 2.BIO是阻塞的,NIO是非阻塞的 3.BIO基于字节流或者字符流进行操作,而NIO基于Channel(通道)和Buffer(缓存区)进行操作,数据总是从通道读取到缓 阅读全文
posted @ 2022-08-15 22:10 努力的达子 阅读(26) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2022-08-15 20:25 努力的达子 阅读(12) 评论(0) 推荐(0) 编辑
摘要: 如何再BIO下实现任意类型的文件传输呢? 1.服务端代码: public class Server { public static void main(String[] args) { try { ServerSocket ss = new ServerSocket(8888); System.ou 阅读全文
posted @ 2022-08-10 21:24 努力的达子 阅读(47) 评论(0) 推荐(0) 编辑
摘要: 样例: 1.定义一个线程池处理类: public class HandlerSocketServerPool { private ExecutorService executorService; public HandlerSocketServerPool() { this.executorServ 阅读全文
posted @ 2022-08-09 21:13 努力的达子 阅读(17) 评论(0) 推荐(0) 编辑
摘要: 1.服务端代码: public class Server { public static void main(String[] args) { try { System.out.println(" 服务端启动 "); //1.定义一个ServerSocket对象进行服务端的端口注册 ServerSo 阅读全文
posted @ 2022-08-04 22:28 努力的达子 阅读(46) 评论(0) 推荐(0) 编辑
摘要: 1.如何实现客户端多次发消息,服务端多次接收的情况呢 1.服务端 /** * 目标:客户端发送消息,服务端接收消息 */ public class Server { public static void main(String[] args) { try { System.out.println(" 阅读全文
posted @ 2022-08-04 21:15 努力的达子 阅读(40) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 ··· 25 下一页