tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Writing to multiple descriptors with one system call

In article <>,
Sad Clouds  <> wrote:
>On Wed, 17 Mar 2010 12:50:51 +0000
>Sad Clouds <> wrote:
>> Hi is there some undocumented system call that allows a user process
>> to write to multiple descriptors in one go?
>> What I'm looking for is a variation of writev() system call, e.g.:
>> size_t write2v(int *d, int dcnt, const struct iovec *iov, int iovcnt);
>> So the application builds an array of file descriptors and an array of
>> iovec structures. It then calls write2v(), which goes through each
>> file descriptor and writes buffers from iovec structures.
>On second thoughts, there needs to be a way to handle partial writes
>struct fdvec
>       int fd;
>       size_t nwritten;
>int write2v(
>       struct fdvec *fdv, int fdvcnt, const struct iovec *iov, int iovcnt);
>For each file descriptor, the function sets nwritten to the number of
>bytes written. It returns 0 when all buffers in iovec structures were
>written to all file descriptors, otherwise it returns >0 for each file
>descriptor that was partially written.

if you are going to build that, then it is probably easier to include
all the info in the iovec:

struct iovec2 {
        int iov_fd;
        int iov_errno;
        ssize_t iov_nwritten;
        void *iov_base;
        size_t iov_len;

int writev2(const struct iovec2 *iov, size_t iovcnt);

And then you have to define the semantics of what to do on error (continue with
the next fd or abort). It is pretty simple to write otherwise, since you
can just call the old writev call in a loop for each...


Home | Main Index | Thread Index | Old Index