(no subject)

Aug 17, 2011 02:37

Goddamn, just found a thorny bit in .net while working with named pipes. I couldn't figure out why the following (simplified!) code was complaining that the named pipe was in use:

_pipe = new NamedPipeServerStream("my name", ..);
_pipe.close();
_pipe = new NamedPipeServerStream("my name", ..);

(obviously, it's much harder to figure out in the real code).

Anyway - calling .Close (or .Dispose :|) on the pipe doesn't _actually_ dispose the named pipe object - just the Stream which the pipe inherits from. So, while the Stream was closed, the pipe itself wasn't 'closed' as such, causing the second instrumentation to fail. Instead, I ended up doing this:

_pipe = new NamedPipeServerStream("my name", ..);
_pipe.Dsconnect();
_pipe.close();
_pipe = new NamedPipeServerStream("my name", ..);

Goddamn. Hopefully this is useful for someone else..

namedpipeserverstream, c#, .net, named pipes

Previous post Next post
Up