Reliable Datagram / Stream behaviour of NT Pipes

Juan Lang juan.lang at
Fri Jan 30 12:41:49 CST 2009

Hi Luke,

On Fri, Jan 30, 2009 at 9:22 AM, Luke Kenneth Casson Leighton
<lkcl at> wrote:
> i've encountered some bugs (thanks to python again :) ) in the wine
> implementation of nt named pipes, and have raised it as a bug
> but it started getting
> complicated so i thought i'd best raise it here.
> the behaviour of nt named pipes is a cross between datagrams and
> streams - it's the best of both worlds:
> * absolute inviolate message sizes (datagrams)
> * absolute inviolate message order (streams).
> the issue with the implementation of nt named pipes on top of _just_
> streams (unix sockets) is this: two packets sent get blatted into one
> read.

You are correct.  We've known about that bug for ages, but never got
around to fixing it.  See e.g. Mike McCormack's interview and his
comments on message mode:

> ... i'm veery tempted to say "can i have a go at implementing this?"
> but... i know it'll be ... how-to-say... eeenteresting :)
> should i try?

Yes, by all means.

> would an extra server message need to be added (for read), so that the
> server can keep track of how much data has been read back (of the
> current datagram)?

Possibly.  This is tricky too, because a named pipe handle can be
shared across processes.  You really want named pipe reads to block
until a complete datagram is available.  What to do with short reads
is something you'd have to figure out too.  Some nice C test cases
would go a long way toward a correct implementation.

More information about the wine-devel mailing list