Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WCF named pipe minimal example

I'm looking for minimal example of WCF Named Pipes (I expect two minimal applications, server and client, which can communicate via a named pipe.)

Microsoft has the briliant article Getting Started Tutorial that describes WCF via HTTP, and I'm looking for something similar about WCF and named pipes.

I've found several posts in the Internet, but they are a little bit "advanced". I need something minimal, only mandatory functionality, so I can add my code and get the application working.

How do I replace that to use a named pipe?

<endpoint address="http://localhost:8000/ServiceModelSamples/Service/CalculatorService"     binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_ICalculator"     contract="ICalculator" name="WSHttpBinding_ICalculator">     <identity>         <userPrincipalName value="OlegPc\Oleg" />     </identity> </endpoint> 

How do I replace that to use a named pipe?

// Step 1 of the address configuration procedure: Create a URI to serve as the base address. Uri baseAddress = new Uri("http://localhost:8000/ServiceModelSamples/Service");  // Step 2 of the hosting procedure: Create ServiceHost ServiceHost selfHost = new ServiceHost(typeof(CalculatorService), baseAddress);  try {     // Step 3 of the hosting procedure: Add a service endpoint.     selfHost.AddServiceEndpoint(         typeof(ICalculator),         new WSHttpBinding(),         "CalculatorService");      // Step 4 of the hosting procedure: Enable metadata exchange.     ServiceMetadataBehavior smb = new ServiceMetadataBehavior();     smb.HttpGetEnabled = true;     selfHost.Description.Behaviors.Add(smb);      // Step 5 of the hosting procedure: Start (and then stop) the service.     selfHost.Open();     Console.WriteLine("The service is ready.");     Console.WriteLine("Press <ENTER> to terminate service.");     Console.WriteLine();     Console.ReadLine();      // Close the ServiceHostBase to shutdown the service.     selfHost.Close(); } catch (CommunicationException ce) {     Console.WriteLine("An exception occurred: {0}", ce.Message);     selfHost.Abort(); } 

How do I generate a client to use a named pipe?

like image 999
Oleg Vazhnev Avatar asked Sep 08 '11 19:09

Oleg Vazhnev


People also ask

What is named pipe in WCF?

A named pipe is an object in the Windows operating system kernel, such as a section of shared memory that processes can use for communication. A named pipe has a name, and can be used for one-way or duplex communication between processes on a single machine.

What is NetNamedPipeBinding?

The NetNamedPipeBinding generates a run-time communication stack by default, which uses transport security, named pipes for message delivery, and a binary message encoding. This binding is an appropriate Windows Communication Foundation (WCF) system-provided choice for on-machine communication.

What transport protocols are supported in WCF?

Protocols − WCF supports a range of protocols, i.e., HTTP, Named Pipes, TCP, and MSMQ, whereas a web service only supports HTTP protocol.

What is WCF service?

Windows Communication Foundation (WCF) is a framework for building service-oriented applications. Using WCF, you can send data as asynchronous messages from one service endpoint to another. A service endpoint can be part of a continuously available service hosted by IIS, or it can be a service hosted in an application.


1 Answers

I just found this excellent little tutorial. broken link (Cached version)

I also followed Microsoft's tutorial which is nice, but I only needed pipes as well.

As you can see, you don't need configuration files and all that messy stuff.

By the way, he uses both HTTP and pipes. Just remove all code lines related to HTTP, and you'll get a pure pipe example.

like image 161
Juan Avatar answered Sep 22 '22 06:09

Juan