using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Cosmos.System.Network.IPv4 { /// /// EndPoint class. /// public class EndPoint : IComparable { /// /// Address. /// internal Address address; /// /// Port. /// internal UInt16 port; /// /// Create new inctanse of the class. /// /// Adress. /// Port. public EndPoint(Address addr, UInt16 port) { this.address = addr; this.port = port; } /// /// To string. /// /// string value. public override string ToString() { return this.address.ToString() + ":" + this.port.ToString(); } /// /// Compare end points. /// /// Other end point to compare to. /// -1 if end points are diffrent, 0 if equal. /// Thrown if obj is not a EndPoint. public int CompareTo(object obj) { if (obj is EndPoint) { EndPoint other = (EndPoint)obj; if ((other.address.CompareTo(this.address) != 0) || (other.port != this.port)) { return -1; } return 0; } else throw new ArgumentException("obj is not a IPv4EndPoint", "obj"); } } }