|
using System;
using System.Runtime.InteropServices;
namespace Peer.Graph
{
public class PeerNode
{
private System.Int64 nodeId;
private string peerId;
internal PEER_ADDRESS[] addresses;
private string attributes;
internal PeerNode(PEER_NODE_INFO info)
{
nodeId = info.ullNodeId;
peerId = info.pwzPeerId;
addresses = new PEER_ADDRESS[info.cAddresses];
int size = Marshal.SizeOf(typeof(PEER_ADDRESS));
for (int i = 0; i < info.cAddresses; i++)
{
addresses[i] = (PEER_ADDRESS)Marshal.PtrToStructure((IntPtr)(info.pAddresses.ToInt32()+i*size), typeof(PEER_ADDRESS));
}
attributes = info.pwzAttributes;
}
public System.Int64 NodeId
{
get
{
return nodeId;
}
}
public string PeerId
{
get
{
return peerId;
}
}
public System.Net.IPEndPoint[] Addresses
{
get
{
System.Net.IPEndPoint[] result = new System.Net.IPEndPoint[addresses.Length];
for (int i = 0; i < addresses.Length; i++)
{
result[i] = new System.Net.IPEndPoint(new System.Net.IPAddress(addresses[i].sin6.sin6_addr), addresses[i].sin6.sin6_port);
}
return result;
}
}
public string Attributes
{
get
{
return attributes;
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
Adrian Moore is the Development Manager for the SCADA Vision system developed by ABB Inc in Calgary, Alberta.
He has been interested in compilers, parsers, real-time database systems and peer-to-peer solutions since the early 90's. In his spare time, he is currently working on a SQL parser for querying .NET DataSets (http://www.queryadataset.com).
Adrian is a Microsoft MVP for Windows Networking.