PeerNameResolver.Resolve Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Resolves a PeerName object to a PeerNameRecord using the PNRP protocol.
Overloads
Resolve(PeerName) |
Resolves the specified PeerName in all clouds known to the calling peer. |
Resolve(PeerName, Int32) |
Resolves the specified peer name in all clouds known to the calling peer, returning no more than the specified number of PeerNameRecord objects. |
Resolve(PeerName, Cloud) | |
Resolve(PeerName, Cloud, Int32) |
Resolves the specified PeerName in the specified Cloud, returning no more than the specified number of PeerNameRecord objects. |
Remarks
This method associates peer names to clouds. Calling the PeerNameResolver method is similar to calling the Resolve method for each peer name record in the PeerNameRecordCollection. Note that using the Resolve method on an individual peer name record does not invalidate resolving multiple peer names.
For every Resolve method, there is an equivalent ResolveAsync method. They are identical in the parameters they are passed, except that the ResolveAsync method includes a system token in its parameter list for asynchronous event handling.
If the Cloud parameter is not supplied, the method uses the Available shortcut to fill in cloud parameters. If the maxRecords
parameter is missing, the default value of zero causes an ArgumentOutOfRangeException exception to be thrown.
This event will also be raised if the resolve operation completes in error or is canceled.
Resolve(PeerName)
Resolves the specified PeerName in all clouds known to the calling peer.
public:
System::Net::PeerToPeer::PeerNameRecordCollection ^ Resolve(System::Net::PeerToPeer::PeerName ^ peerName);
public System.Net.PeerToPeer.PeerNameRecordCollection Resolve (System.Net.PeerToPeer.PeerName peerName);
member this.Resolve : System.Net.PeerToPeer.PeerName -> System.Net.PeerToPeer.PeerNameRecordCollection
Public Function Resolve (peerName As PeerName) As PeerNameRecordCollection
Parameters
Returns
A PeerNameRecordCollection that contains all peer name records (represented as PeerNameRecord objects) associated with the specified peer name. For unsecured peer names, the same PeerName can be registered by different users in the same Cloud, and associated with different endpoints.
Exceptions
The peerName
parameter is set to null
.
The peer name specified cannot be resolved.
Examples
The following code example illustrates how to resolve a PeerName published in any Cloud.
static void Main(string[] args)
{
try
{
if (args.Length != 1)
{
Console.WriteLine("Usage: PeerNameResolver.exe <PeerNameToResolve>");
return;
}
// create a resolver object to resolve a Peer Name that was previously published
PeerNameResolver resolver = new PeerNameResolver();
// The Peer Name to resolve must be passed as the first
// command line argument to the application
PeerName peerName = new PeerName(args[0]);
// Resolve the Peer Name
// This is a network operation and will block until the resolve completes
PeerNameRecordCollection results = resolver.Resolve(peerName);
// Display the data returned by the resolve operation
Console.WriteLine("Resolve operation complete.\n", peerName);
Console.WriteLine("Results for PeerName: {0}", peerName);
Console.WriteLine();
int count = 1;
foreach (PeerNameRecord record in results)
{
Console.WriteLine("Record #{0} results...", count);
Console.Write("Comment:");
if (record.Comment != null)
{
Console.Write(record.Comment);
}
Console.WriteLine();
Console.Write("Data:");
if (record.Data != null)
{
// Assumes the data blob associated with the PeerName
// is made up of ASCII characters
Console.Write(System.Text.Encoding.ASCII.GetString(record.Data));
}
Console.WriteLine();
Console.WriteLine("Endpoints:");
foreach (IPEndPoint endpoint in record.EndPointCollection)
{
Console.WriteLine("\t Endpoint:{0}", endpoint);
Console.WriteLine();
}
count++;
}
Console.ReadKey();
}
catch (Exception e)
{
Console.WriteLine("Error occurred while attempting to resolve the PeerName: {0}", e.Message);
Console.WriteLine(e.StackTrace);
// P2P is not supported on Windows Server 2003
if (e.InnerException != null)
{
Console.WriteLine("Inner Exception is {0}", e.InnerException);
}
}
}
Remarks
This method associates a peer name to clouds. All clouds are queried for the PeerName. If the peer name cannot be resolved or is null
, an PeerToPeerException is thrown.
For unsecured peer names, the same name can be registered (and associated with different endpoints) by different peers within the same cloud.
Calling the PeerNameResolver method is similar to calling the Resolve method for each peer name record in the PeerNameRecordCollection. Note that using the Resolve method on an individual peer name record does not invalidate resolving multiple peer names.
For every Resolve method, there is an equivalent ResolveAsync method. Their parameter lists are identical, except that the ResolveAsync method includes a system token for asynchronous event handling.
If the Cloud parameter is not supplied, the method uses the Available shortcut to fill in cloud parameters.
The ResolveCompleted event will be raised if the resolve operation completes in error or is canceled.
See also
Applies to
Resolve(PeerName, Int32)
Resolves the specified peer name in all clouds known to the calling peer, returning no more than the specified number of PeerNameRecord objects.
public:
System::Net::PeerToPeer::PeerNameRecordCollection ^ Resolve(System::Net::PeerToPeer::PeerName ^ peerName, int maxRecords);
public System.Net.PeerToPeer.PeerNameRecordCollection Resolve (System.Net.PeerToPeer.PeerName peerName, int maxRecords);
member this.Resolve : System.Net.PeerToPeer.PeerName * int -> System.Net.PeerToPeer.PeerNameRecordCollection
Public Function Resolve (peerName As PeerName, maxRecords As Integer) As PeerNameRecordCollection
Parameters
- maxRecords
- Int32
The maximum number of PeerNameRecord objects to obtain from all Cloud objects for the supplied peerName
.
Returns
A PeerNameRecordCollection whose size is less than or equal to maxRecords
entries. This collection contains peer name records associated with the PeerName that was resolved.
Exceptions
The peerName
parameter is set to null
.
The maxRecords
parameter is less than or equal to zero.
The supplied peer name cannot be resolved.
Remarks
This method associates a peer name to clouds. All clouds are queried for the peer name. For unsecured peer names, the same peer name can be registered by different users in the same Cloud, and associated with different endpoints. If the PeerName cannot be resolved (for example, the peer name is not published) an PeerToPeerException is thrown.
For every Resolve method, there is an equivalent ResolveAsync method. Their parameter lists are identical, except that the ResolveAsync method includes a system token for asynchronous event handling.
The ResolveCompleted event will be raised if the resolve operation completes in error or is canceled.
Applies to
Resolve(PeerName, Cloud)
public:
System::Net::PeerToPeer::PeerNameRecordCollection ^ Resolve(System::Net::PeerToPeer::PeerName ^ peerName, System::Net::PeerToPeer::Cloud ^ cloud);
public System.Net.PeerToPeer.PeerNameRecordCollection Resolve (System.Net.PeerToPeer.PeerName peerName, System.Net.PeerToPeer.Cloud cloud);
member this.Resolve : System.Net.PeerToPeer.PeerName * System.Net.PeerToPeer.Cloud -> System.Net.PeerToPeer.PeerNameRecordCollection
Public Function Resolve (peerName As PeerName, cloud As Cloud) As PeerNameRecordCollection
Parameters
Returns
PeerNameRecordCollection that contains all peer name records (represented as PeerNameRecord objects) associated with the specified peer name. For unsecured peer names, the same PeerName can be registered by different users in the same Cloud, and associated with different endpoints.
Exceptions
The peerName
parameter is set to null
.
The supplied peer name cannot be resolved.
Remarks
If the PeerName cannot be resolved (that is, the peer name is not published) an PeerToPeerException is thrown.
For unsecured peer names, the same name can be registered (and associated with different endpoints) by different peers within the same cloud.
For every Resolve method, there is an equivalent ResolveAsync method. Their parameter lists are identical, except that the ResolveAsync method includes a system token for asynchronous event handling.
If the Cloud parameter is null
, the PeerNameResolver uses the Available shortcut to fill in the Name, Scope, and ScopeId.
The ResolveCompleted event will be raised if the resolve operation completes in error or is canceled.
Applies to
Resolve(PeerName, Cloud, Int32)
Resolves the specified PeerName in the specified Cloud, returning no more than the specified number of PeerNameRecord objects.
public:
System::Net::PeerToPeer::PeerNameRecordCollection ^ Resolve(System::Net::PeerToPeer::PeerName ^ peerName, System::Net::PeerToPeer::Cloud ^ cloud, int maxRecords);
[System.Security.SecurityCritical]
public System.Net.PeerToPeer.PeerNameRecordCollection Resolve (System.Net.PeerToPeer.PeerName peerName, System.Net.PeerToPeer.Cloud cloud, int maxRecords);
[<System.Security.SecurityCritical>]
member this.Resolve : System.Net.PeerToPeer.PeerName * System.Net.PeerToPeer.Cloud * int -> System.Net.PeerToPeer.PeerNameRecordCollection
Public Function Resolve (peerName As PeerName, cloud As Cloud, maxRecords As Integer) As PeerNameRecordCollection
Parameters
- maxRecords
- Int32
The maximum number of peer name record objects to obtain from the specified cloud for the specified peerName
.
Returns
A PeerNameRecordCollection whose size is less than or equal to maxRecords
entries. This collection contains peer name records associated with the PeerName that was resolved.
- Attributes
Exceptions
The peerName
parameter is set to null
.
The maxRecords
parameter is less than or equal to zero.
The supplied peer name cannot be resolved.
Remarks
For unsecured peer names, the same name can be registered (and associated with different endpoints) by different peers within the same cloud. If the peer name cannot be resolved, an PeerToPeerException is thrown.
For every Resolve method, there is an equivalent ResolveAsync method. Their parameter lists are identical, except that the ResolveAsync method includes a system token for asynchronous event handling.
If the Cloud parameter is null
, the PeerNameResolver uses the Available shortcut to fill in the Name, Scope, and ScopeId.
The ResolveCompleted event will be raised if the resolve operation completes in error or is canceled.