Boost logo

Boost :

Subject: Re: [boost] [Interprocess] Named pipe interface proposal
From: Geoff Shannon (geoffpshannon_at_[hidden])
Date: 2013-08-12 19:27:02


On Mon, Aug 12, 2013 at 8:58 AM, Niall Douglas <ndouglas_at_[hidden]>wrote:

> 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.
>

I like this idea. I wasn't sure it was appropriate though and frankly,
from having poked through the source a bit, ASIO is a bit intimidating in
the way it's structured. But I'm sure that's mostly a lack of familiarity
with it and only vaguely understanding the core principles which can surely
be remedied by some study of the documentation.

> 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.
>

Hmmm, I see what you're saying and I agree with it, but I'm also not sure
that it's strictly true that this is the "only" difference. Also, to
clarify when you say POSIX named pipes, you are talking about the mkfifo
call, correct? And is there a reason why the mkfifo call is more desirable
to use than UNIX domain sockets?

> 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 :)
>

I was not! Thanks for the tip :)

Also, FYI, I'm doing this project as an independent study through my CS
program. I'm getting close to the end of the quarter and I need to have
something concrete to show for my efforts. Since I've already started down
the path of implementing this not inside of Boost.ASIO, for the purposes of
my school project I'm going to continue with that. However, I plan to
continue working on it after the scholastic bit is finished, and then I
would be interested in implementing it as part of ASIO.

-- Geoff

Nothing is ever easy.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk