AFAICS, the functions of the read / write vector work in the same way as the short short read / write, as usual. That is, you return the number of bytes read / written, but this can indicate the middle of the structure, as well as read () / write (). There is no guarantee that possible “breakpoints” (due to the lack of a better term) coincide with the borders of the vector. Therefore, unfortunately, the vector I / O functions no longer help to cope with short reads / writes than the usual I / O functions. This is actually more complicated since you need to map the byte count in the vector I / O element and the offset inside the element.
Also note that the idea of using vector I / O for individual structures or data elements may not work as well; the maximum allowable value for the iovcnt argument (IOV_MAX) is usually quite small, about 1024 or so. Therefore, if you data are adjacent in memory, just pass it as one element, and not artificially split it.
source share