using System; using System.Net.Sockets; namespace System.Net { /// Represents a network endpoint as an IP address and a port number. // Token: 0x02000241 RID: 577 [Serializable] public class IPEndPoint : EndPoint { /// Initializes a new instance of the class with the specified address and port number. /// An . /// The port number associated with the , or 0 to specify any available port. is in host order. /// /// is less than .-or- is greater than .-or- is less than 0 or greater than 0x00000000FFFFFFFF. // Token: 0x06001491 RID: 5265 RVA: 0x00041828 File Offset: 0x0003FA28 public IPEndPoint(IPAddress address, int port) { if (address == null) { throw new ArgumentNullException("address"); } this.Address = address; this.Port = port; } /// Initializes a new instance of the class with the specified address and port number. /// The IP address of the Internet host. /// The port number associated with the , or 0 to specify any available port. is in host order. /// /// is less than .-or- is greater than .-or- is less than 0 or greater than 0x00000000FFFFFFFF. // Token: 0x06001492 RID: 5266 RVA: 0x00041850 File Offset: 0x0003FA50 public IPEndPoint(long iaddr, int port) { this.Address = new IPAddress(iaddr); this.Port = port; } /// Gets or sets the IP address of the endpoint. /// An instance containing the IP address of the endpoint. // Token: 0x170006BD RID: 1725 // (get) Token: 0x06001493 RID: 5267 RVA: 0x0004186C File Offset: 0x0003FA6C // (set) Token: 0x06001494 RID: 5268 RVA: 0x00041874 File Offset: 0x0003FA74 public IPAddress Address { get { return this.address; } set { this.address = value; } } /// Gets the Internet Protocol (IP) address family. /// Returns . // Token: 0x170006BE RID: 1726 // (get) Token: 0x06001495 RID: 5269 RVA: 0x00041880 File Offset: 0x0003FA80 public override global::System.Net.Sockets.AddressFamily AddressFamily { get { return this.address.AddressFamily; } } /// Gets or sets the port number of the endpoint. /// An integer value in the range to indicating the port number of the endpoint. /// The value that was specified for a set operation is less than or greater than . // Token: 0x170006BF RID: 1727 // (get) Token: 0x06001496 RID: 5270 RVA: 0x00041890 File Offset: 0x0003FA90 // (set) Token: 0x06001497 RID: 5271 RVA: 0x00041898 File Offset: 0x0003FA98 public int Port { get { return this.port; } set { if (value < 0 || value > 65535) { throw new ArgumentOutOfRangeException("Invalid port"); } this.port = value; } } /// Creates an endpoint from a socket address. /// An instance using the specified socket address. /// The to use for the endpoint. /// The AddressFamily of is not equal to the AddressFamily of the current instance.-or- .Size < 8. /// /// /// // Token: 0x06001498 RID: 5272 RVA: 0x000418CC File Offset: 0x0003FACC public override EndPoint Create(SocketAddress socketAddress) { if (socketAddress == null) { throw new ArgumentNullException("socketAddress"); } if (socketAddress.Family != this.AddressFamily) { throw new ArgumentException(string.Concat(new object[] { "The IPEndPoint was created using ", this.AddressFamily, " AddressFamily but SocketAddress contains ", socketAddress.Family, " instead, please use the same type." })); } int size = socketAddress.Size; global::System.Net.Sockets.AddressFamily family = socketAddress.Family; global::System.Net.Sockets.AddressFamily addressFamily = family; IPEndPoint ipendPoint; if (addressFamily != global::System.Net.Sockets.AddressFamily.InterNetwork) { if (addressFamily != global::System.Net.Sockets.AddressFamily.InterNetworkV6) { return null; } if (size < 28) { return null; } int num = ((int)socketAddress[2] << 8) + (int)socketAddress[3]; int num2 = (int)socketAddress[24] + ((int)socketAddress[25] << 8) + ((int)socketAddress[26] << 16) + ((int)socketAddress[27] << 24); ushort[] array = new ushort[8]; for (int i = 0; i < 8; i++) { array[i] = (ushort)(((int)socketAddress[8 + i * 2] << 8) + (int)socketAddress[8 + i * 2 + 1]); } ipendPoint = new IPEndPoint(new IPAddress(array, (long)num2), num); } else { if (size < 8) { return null; } int num = ((int)socketAddress[2] << 8) + (int)socketAddress[3]; long num3 = ((long)socketAddress[7] << 24) + ((long)socketAddress[6] << 16) + ((long)socketAddress[5] << 8) + (long)socketAddress[4]; ipendPoint = new IPEndPoint(num3, num); } return ipendPoint; } /// Serializes endpoint information into a instance. /// A instance containing the socket address for the endpoint. // Token: 0x06001499 RID: 5273 RVA: 0x00041A68 File Offset: 0x0003FC68 public override SocketAddress Serialize() { SocketAddress socketAddress = null; global::System.Net.Sockets.AddressFamily addressFamily = this.address.AddressFamily; if (addressFamily != global::System.Net.Sockets.AddressFamily.InterNetwork) { if (addressFamily == global::System.Net.Sockets.AddressFamily.InterNetworkV6) { socketAddress = new SocketAddress(global::System.Net.Sockets.AddressFamily.InterNetworkV6, 28); socketAddress[2] = (byte)((this.port >> 8) & 255); socketAddress[3] = (byte)(this.port & 255); byte[] addressBytes = this.address.GetAddressBytes(); for (int i = 0; i < 16; i++) { socketAddress[8 + i] = addressBytes[i]; } socketAddress[24] = (byte)(this.address.ScopeId & 255L); socketAddress[25] = (byte)((this.address.ScopeId >> 8) & 255L); socketAddress[26] = (byte)((this.address.ScopeId >> 16) & 255L); socketAddress[27] = (byte)((this.address.ScopeId >> 24) & 255L); } } else { socketAddress = new SocketAddress(global::System.Net.Sockets.AddressFamily.InterNetwork, 16); socketAddress[2] = (byte)((this.port >> 8) & 255); socketAddress[3] = (byte)(this.port & 255); long internalIPv4Address = this.address.InternalIPv4Address; socketAddress[4] = (byte)(internalIPv4Address & 255L); socketAddress[5] = (byte)((internalIPv4Address >> 8) & 255L); socketAddress[6] = (byte)((internalIPv4Address >> 16) & 255L); socketAddress[7] = (byte)((internalIPv4Address >> 24) & 255L); } return socketAddress; } /// Returns the IP address and port number of the specified endpoint. /// A string containing the IP address and the port number of the specified endpoint (for example, 192.168.1.2:80). /// /// /// // Token: 0x0600149A RID: 5274 RVA: 0x00041C00 File Offset: 0x0003FE00 public override string ToString() { return this.address.ToString() + ":" + this.port; } /// Determines whether the specified is equal to the current instance. /// true if the specified is equal to the current ; otherwise, false. /// The specified to compare with the current instance. // Token: 0x0600149B RID: 5275 RVA: 0x00041C30 File Offset: 0x0003FE30 public override bool Equals(object obj) { IPEndPoint ipendPoint = obj as IPEndPoint; return ipendPoint != null && ipendPoint.port == this.port && ipendPoint.address.Equals(this.address); } /// Returns a hash value for a instance. /// An integer hash value. /// /// /// // Token: 0x0600149C RID: 5276 RVA: 0x00041C70 File Offset: 0x0003FE70 public override int GetHashCode() { return this.address.GetHashCode() + this.port; } /// Specifies the maximum value that can be assigned to the property. The MaxPort value is set to 0x0000FFFF. This field is read-only. // Token: 0x04001175 RID: 4469 public const int MaxPort = 65535; /// Specifies the minimum value that can be assigned to the property. This field is read-only. // Token: 0x04001176 RID: 4470 public const int MinPort = 0; // Token: 0x04001177 RID: 4471 private IPAddress address; // Token: 0x04001178 RID: 4472 private int port; } }