/* * PROJECT: Aura Operating System Development * CONTENT: End point * PROGRAMMERS: Valentin Charbonnier * Port of Cosmos Code. */ using System; namespace Cosmos.System.Network.IPv4 { /// /// EndPoint class. /// public class EndPoint : IComparable { /// /// Address. /// public Address address; /// /// Port. /// public UInt16 port; /// /// Create new instance 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"); } } }