WCF Named Pipe IPC

Posted by Peter M on Stack Overflow See other posts from Stack Overflow or by Peter M
Published on 2010-06-18T00:32:46Z Indexed on 2010/06/18 0:43 UTC
Read the original article Hit count: 739

I have been trying to get up to speed on Named Pipes this week. The task I am trying to solve with them is that I have an existing windows service that is acting as a device driver that funnels data from an external device into a database. Now I have to modify this service and add an optional user front end (on the same machine, using a form of IPC) that can monitor the data as it passes between the device and the DB as well as send some commands back to the service.

My initial ideas for the IPC were either named pipes or memory mapped files. So far I have been working through the named pipe idea using WCF Tutorial Basic Interprocess Communication . My idea is to set the Windows service up with an additional thread that implements the WCF NamedPipe Service and use that as a conduit to the internals of my driver.

I have the sample code working, however I can not get my head around 2 issues that I am hoping that someone here can help me with:

  1. In the tutorial the ServiceHost is instantiated with a typeof(StringReverser) rather than by referencing a concrete class. Thus there seems to be no mechanism for the Server to interact with the service itself (between the host.Open() and host.Close() lines). Is it possible to create a link between and pass information between the server and the class that actually implements the service? If so, how?

  2. If I run a single instance of the server and then run multiple instance of the clients, it seems that each client gets a separate instance of the service class. I tried adding some state information to the class implementing the service and it was only retained within the instance of the named pipe. This is possibly related to the first question, but is there anyway to force the named pipes to use the same instance of the class that is implementing the service?

  3. Finally, any thoughts on MMF vs Named Pipes?

Thanks for you help

© Stack Overflow or respective owner

Related posts about wcf

Related posts about named-pipes