Subject: Re: [boost] [Interprocess] Named pipe interface proposal
From: Niall Douglas (ndouglas_at_[hidden])
Date: 2013-08-12 11:58:26
> I emailed the list a while ago that I was starting to work on a named pipe
> implementation for potential inclusion in the Boost.Interprocess library,
> now I finally have some concrete evidence of progress. I've come up with
> header file for my proposed interface and I would really appreciate any
> feedback on it.
> Particularly, I'm interested in ideas for an appropriate replacement for
> char *'s as the data buffers for reading and writing.
> As a point of interest this interface is meant to be extremely simple. I
> intend to initially support ANYTHING except for basic creation and reading
I would URGE you to make this exclusively a Boost.ASIO implementation. That
is the correct fit for pipes, moreover Boost.ASIO does almost all the heavy
lifting for you, especially on Windows where I suspect a Win32 named pipe
implementation will take about eight lines of new code as the ASIO IOCP
backend "just works". There is an IOCP example in the ASIO documentation
which I believe even implements those eight lines for you :)
That solves your data buffers problem, because ASIO already implements
scatter/gather buffer i/o for you. ASIO also already integrates with STL
iostreams and Boost.iostreams for you.
Regarding some of the other comments on this list regarding your proposal:
1. Any async op can be made synchronous by waiting on it. Therefore an ASIO
based named pipe is just as easy to use synchronously as asynchronously.
2. ASIO is the proposed foundation for the future C++ standard networking
library, so adding named pipes there is exactly the right place to enter any
future C++ standard.
3. There seemed to be some confusion regarding named pipes on POSIX. The
only difference between Windows and POSIX named pipes is that the former use
the NT kernel namespace, within which the filing systems are mount points,
whereas the latter use the filing system namespace directly. In my own code,
I use a magic directory in /tmp as the namespace for all my named pipes in
the system in an attempt to replicate a similar behavior to Windows, but
there are many other ways of doing the same thing.
Anonymous pipes are also slightly different - on POSIX they really are
anonymous, whereas on Windows they get given a random hex id for their name.
There is absolutely no reason why on POSIX you can't also use a random hex
id for their name, and indeed that is also exactly what my own code does.
BTW are you aware of the +24 buffer size bug in Windows' pipe
implementation? It's a known bug since very early NT days :)
--- Opinions expressed here are my own and do not necessarily represent those of BlackBerry Inc.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk