wcf - namedPipe dabble in

This post is about dabble in the topic of WCF namedPipe communication, in this post we will desultorily reading through the topic such as how to create a NamedPipe communication , we will also read cursorily on the topic on the difference between net.tcp and net.pipe... It is generally a skim on the effecient cross-process on-machine communication. 

Suppose that you have some service which is in net.tcp, and you have declared the services as something like this: 

<services>
      <!-- TabularPushService -->
      <service name="WcfPub.TabularPushService">
        <endpoint address="net.tcp://127.0.0.1:9999/TabularPushService" binding="netTcpBinding" contract="WcfPub.ITabularPushService" />
      </service>
    </services>    
  </system.serviceModel>
and you might want to change that a named Pipe binding, so the Service might change to something like this:
<service name="WcfPub.TabularPushService">
        <endpoint address="net.pipe://localhost/TabularPushService" binding="netNamedPipeBinding" contract="WcfPub.ITabularPushService" />
      </service>
note in one aspect the endpoint address is specified like this:
net.pipe://localhost/TabularPushService

It looks like that it accept some net port like address, but you cannot apply the http/tcp port here, so it is illegal to use the following notatino for the address URL.

net.pipe://localhost:8080/TabularPushService
To translate this namedPipe binding to code, you will probably get the following.
ServiceEndpoint endpoint = new ServiceEndpoint(
                ContractDescription.GetContract(typeof(ITabularPushService)),
                new NetNamedPipeBinding(),
                new EndpointAddress("net.pipe://localhost/TabularPushService"));

As quoted by MSDN , hereby this is the cited one:

Defines a binding that is secure, reliable, optimized for on-machine cross process communication. By default, it generates a runtime communication stack with WS-ReliableMessaging for reliability, transport security for transfer security, named pipes for message delivery, and binary message encoding.

Reference: 

<netNamedPipeBinding>


你可能感兴趣的:(C#,WCF)