Freigeben über


Getting started- A Fresh look at Peer Channel (NetPeerTcpBinding)

Allright,the general consensus amongst new adopters/potential customers seems to be, that our documentation on msdn seems to be not all that crystal-clear, especially for a new comer, to Peer Channel. And that uptil now, we have been targetting advanced scenarios in our blog - Since it might take a while for us to get stuff added/edited up on msdn, we decided to get some basic stuff up on the blog. So, now shall follow some posts about Peer Channel basics - hopefully, from what i think is scratch :).Feel free to comment on the topics covered and on topics you would like covered here in this section..

Where you will find us:  

Peer Channel is enabled by default on Windows Vista - as is all of WCF. So you no longer have to download the runtime components (primarily System.ServiceModel.dll) separately or enable it explicitly.

So all you really need to get started is to add references to System.ServiceModel.dll in your project & you should have access to our classes.

What are we (in terms of WCF):

We are essentially a virtual WCF channel - an abstraction built on top of the WCF TCP channel that provides a means for peer-peer communication, without the application having to worry about it. Most of this functionality is exposed to a WCF application through the NetPeerTcpBinding. It is through the NetPeerTcpBinding that you can configure and query static and instance properties like, IsPnrpAvailable, regular properties that can be set on any WCF binding (eg timeouts), and peer-channel specific properties like Resolver (name resolution), Security options etc..

Default behavior/Properties:

(a) Name Resolution: Our default peer name resolution mechanism uses a resolver based on PNRP the PnrpResolver. This is available on XPSP2 (with Networking pack installed) and by default on Windows Vista. Incase, you dont wish to use Pnrp, you have two other options -

       i) DefaultCustomResolver: a WCF TCP service-based name resolver; an implementation we provide out-of-the-box. All you need to do is configure the Resolver property on the NetPeerTcpbinding instance. There are some more configuration steps and our scenario sample on msdn shows how to configure your app to use this resolver.

       ii) Custom Resolver - There are times where you might to use your own discovery resolver - for this you can plug in your custom name resolver again by specifying the NetPeerTcpBinding's resolver property with the type of your resolver class. We also ship a custom resolver implementation (again TCP-based) sample for reference.

(b) Security: By default, Peer channel uses password-based authentication for communication amongst peers. So make sure to configure your password on the instance of channelFactory through teh Credential.Peer.MeshPassword property. The certificates used in this authentication are auto-generated and need not be generated/set explicitly, but your application can do so using the Credential.Peer.Certificate property. Our samples show best how this and other security modes can be used with Peer Channel. We'll also cover more on this in a later post..

(c) Listen port: Ports on which your node is listening are auto-generated. So it is really simple for you to run multiple instances of your application on the same machine without any configuration changes. If you would like to explicitly set the port your application should listen on, use the Port property on the netPeerTcpBinding instance.

(d) Listen IPAddress: By default, Peer Channel uses all available IPv4/IPv6 addresses to bind to (including link-local/global IPv6 addresses). However, if you choose, you can make it listen on specific IP addresses using the ListenIPAddress property on binding instance.

Hopefully, I've covered some basics, and this post, coupled with the samples on msdn, should help you get started with writing your first Peer Channel app :). Stay tuned for more fun stuff :)

Comments

  • Anonymous
    March 11, 2009
    how can i use NetPeerTcpBinding with returned methods so when my method not void i get error System.InvalidOperationException: Contract requires Request/Reply, but Binding 'net.p2p://10.100.28.96/ledger' doesn't support it or isn't configured properly to support it.

  • Anonymous
    October 25, 2009
    You cannot unfortunately; We only support one-way message contracts.