READV and Writev functions

Source: Internet
Author: User

The readv and Writev functions are used to read and write multiple non-contiguous buffers in a function call. These two functions are sometimes referred to as scatter-read and aggregate- write .

#include <sys/uio.h>ssize_t readv(intconststructint iovcnt);ssize_t writev(intconststructint iovcnt);

The second argument to these two functions is a pointer to an array of IOVEC structures:

struct iovec {    void  *iov_base;    /* Starting address */    size_t iov_len;     /* Number of bytes to transfer */};

The number of elements in the Iov Array is explained by iovcnt .

Writev to aggregate output data from a buffer in order Iov[0], iov[1] through iov[iovcnt-1], WRITEV returns the total number of bytes of output, usually equal to the sum of all buffer lengths.

READV the read data into the buffer in the same order as above, Readv always fills a buffer first, and then fills in the next, READV returns the total number of bytes read, and if there is no data to read at the end of the file, 0 is returned.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

READV and Writev functions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.