ZeroCopy 和javaNIO的ZeroCopy

https://www.linuxjournal.com/article/6345?page=0,1

https://www.jianshu.com/p/fad3339e3448

File file = new File("fileName");
RandomAccessFile raf = new RandomAccessFile(file, "rw");
FileChannel fileChannel = raf.getChannel();
SocketChannel socketChannel = SocketChannel.open(new InetSocketAddress("host",port));
// 不拷贝至用户空间也不会从读缓冲区拷贝至网络缓冲区
fileChannel.transferTo(0, fileChannel.size(), socketChannel);

猜你喜欢

转载自blog.csdn.net/Tiggcat/article/details/105606128
今日推荐