Mou
Mou

Reputation: 16282

WCF netNamedPipeBinding and shared memory for their communication

people are saying that netNamedPipeBinding is used in wcf when they want two wcf service interact with each other and share data. i was searching google and i found many samples for wcf netNamedPipeBinding but none of them use netNamedPipeBinding to share memory for communication purpose. so it my request if anyone knows about any article on wcf netNamedPipeBinding which guide me how two wcf services can share memory between them using netNamedPipeBinding protocol then please redirect me to that article.

i want to run two wcf service in same pc and what to see how two wcf service can share the same memory and interact with each other. when it will be successful then i want to run two wcf service on two different pc for sharing memory ? looking for help. thanks

Upvotes: 2

Views: 3123

Answers (2)

YK1
YK1

Reputation: 7602

You don't have to do anything special to use shared memory. WCF netNamedPipeBinding internally uses memory mapped files to communicate between two processes running on the same computer - it is the quickest way two processes running on same computer can communicate via WCF.

See this article.

However, at the same time, it is also a limitation, that because it uses shared memory object (memory mapped file), both communicating parties have to be running on same computer.

To communicate across two computers using WCF, you will have to use some other binding:

C# - WCF - inter-process communication

Upvotes: 3

asafrob
asafrob

Reputation: 1858

Basically the use is the same as with other WCF communications and as far as I know the memory is not actually shared, but one process can get stuff to memory and pass them to the other process. The difference is in how you define your endpoints.

This is a server endpoint definition:

  <system.serviceModel>
    <services>
      <service name="aaa.bbb">
        <endpoint address="net.pipe://localhost/lalala" binding="netNamedPipeBinding" contract="aaa.Ibbb">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8733/Design_Time_Addresses/aaa/Service1/" />
          </baseAddresses>
        </host>
      </service>
    </services>

and this is the client side:

NetNamedPipeBinding nnpb = new NetNamedPipeBinding();
nnpb.MaxReceivedMessageSize = 65536000;

ChannelFactory<aaa.Ibbb> Factory =
                new ChannelFactory<aaa.Ibbb>(nnpb, new EndpointAddress("net.pipe://localhost/lalala"));

aaa.Ibbb proxy = Factory.CreateChannel();

var a = proxy.DoSomething();

use any of these keywords and you can probably find some tutorials.

Upvotes: 0

Related Questions