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



On Wed, Mar 17, 2010 at 05:17:52PM +0000, Christos Zoulas wrote:
> In article 
> <20100317131044.f26d5d99.cryintothebluesky%googlemail.com@localhost>,
> Sad Clouds  <cryintothebluesky%googlemail.com@localhost> wrote:
> >On Wed, 17 Mar 2010 12:50:51 +0000
> >Sad Clouds <cryintothebluesky%googlemail.com@localhost> 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:

I think you missed his point here, which is to write the *same* data to
all fds, and not to match a vector to a fd.  It could work too, but then
instead of having 5000 struct fdvec and two struct iovec, you'd end up
with 10000 struct iovec2.

-- 
Quentin Garnier - cube%cubidou.net@localhost - cube%NetBSD.org@localhost
"See the look on my face from staying too long in one place
[...] every time the morning breaks I know I'm closer to falling"
KT Tunstall, Saving My Face, Drastic Fantastic, 2007.

Attachment: pgphAg6p2VpX1.pgp
Description: PGP signature



Home | Main Index | Thread Index | Old Index