[Mono-list] Connected streams?

Chris Howie cdhowie at gmail.com
Wed Oct 14 23:02:15 EDT 2009

Hello folks.

I've been milling this around in my head for a while and dug into
several parts of the framework, and I can't seem to find anything
usable.  I need to create a pair of streams, so that what I write into
stream A goes into B's read buffer, and vice-versa.  Think pipe(),
only bidirectional, or socketpair() without the sockets.  The idea is
to write unit tests for client and server objects in the same process,
without resorting to e.g. having the test listen on some random TCP
port and connect to itself.

The closest I've come is several of the classes in System.IO.Pipes,
and even those don't look perfect.  For example, I can't have a
bidirectional anonymous pipe, and a named pipe could clash with others
on the same system.  It seems probable to me that some purely managed
solution would exist already, but Google is not forthcoming and I
would really *really* like to avoid coding something that ugly just
for a unit test...

Any ideas?

Chris Howie

More information about the Mono-list mailing list