readv和writev函数用于在一次函数调用中读、写多个非连续缓冲区。有时也将这两个函数称为散布读(scatter read)和聚集写(gather write)。

#include <sys/uio.h>
ssize_t readv(int filedes, const struct iovec *iov, int iovcnt); #散布读
ssize_t writev(int filedes, const struct iovec *iov, int iovcnt); #聚集写

其中的iovec

#include <sys/uio.h>
struct iovec {
    ptr_t iov_base; /* Starting address */
    size_t iov_len; /* Length in bytes */
};

代码:https://github.com/vcvvvc/CPP_Test/tree/master/test/writev


Re:

https://www.cnblogs.com/nufangrensheng/p/3559304.html

https://www.cnblogs.com/youngerchina/p/5624567.html