PeerToPeer Technology Sample
[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]
This sample shows how to use the new classes in the System.Net.PeerToPeer namespace to register and publish a peer name, and then resolve a peer name.
For information about using the samples, see the following topics:
To build the sample using the Command Prompt
Open the Command Prompt window and navigate to the CS subdirectory under the PNRPSample directory. For information about required settings and the SDK Command Prompt, see How to: Set Sample Settings.
Type msbuild PNRPSample.sln at the command line. This command will build both the PublishPeerName and ResolvePeerName applications.
To build the sample using Visual Studio
Open Windows Explorer and navigate to the CS subdirectory under the PNRPSample directory.
Double-click the icon for PNRPSample.sln to open the file in Visual Studio.
In the Build menu, select Build Solution.
Both the PublishPeerName and ResolvePeerName applications are built in the default \bin or \bin\Debug directory.
To run the sample
Navigate to the directory that contains the new executable files, using the Command Prompt window.
Type PublishPeerName.exe at the command line with appropriate command-line arguments to run the PublishPeerName application.
Type ResolvePeerName.exe at the command line with appropriate parameters to run the ResolvePeerName application for testing the PublishPeerName application.
A series of new classes have been added in the System.Net.PeerToPeer and System.Net.PeerToPeer.Collaboration namespaces that support peer-to-peer networking and collaboration for sharing resources among peers.
This sample demonstrates using the Peer Name Resolution Protocol (PNRP), a serverless name resolution technology, to publish and resolve a PeerName. It allows an application to create an identifier (known as a peer name), associate that identifier with data (for example, an IP address, port number, and binary blob of data), and publish this information for other peers to be able to resolve. The sample contains two projects. The PublishPeerName sample outlines how to create and publish a peer name. The ResolvePeerName sample shows how to resolve a peer name.
The PublishPeerName application requires five command-line parameters.
PublishPeerName.exe <peerNameClassifier> <peerNameType> <portNum> <comment> <cloudName:Available|AllLinkLocal|Global>
The parameters are as follows:
peerNameClassifier - A user-defined string that will be used as the classifier in the peer name to be published.
PeerNameType - This determines the type of peer name instance to be created and registered. Supported values are Secured and Unsecured.
portNum - The local port number that will be associated with the peer name when it is registered.
comment - A comment string to associate with the peer name. This string is also published and resolvable to PNRP clients.
cloudName - The scope into which the peer name will be published. Supported values are Available, AllLinkLocal, and Global.
An example usage is as follows:
PublishPeerName.exe MyClassifier Secured 8000 CommentString Available
The ResolvePeerName application requires one command-line parameter.
The parameters are as follows:
peerNameToResolve - The peer name that the application will attempt to resolve.
If the ResolvePeerName application is successful, the results of resolving the peer name are displayed.