public class IPAddress
Object
IPAddress
System
Networking
Represents an Internet Protocol (IP) address.
An instance of the IPAddress class contains the value of an address on an IP network. This address is stored internally as a Int64 in network-byte-order.[Note: Different conventions are in use for ordering bytes within multi-byte data types. All IP address values must be sent over the network in network-byte-order. Network-byte-order puts the most significant byte first (also known as big-endian order). On the host, the ordering of bytes is platform-specific and this ordering is referred to as host-byte-order.]
The IP address can be represented as four numbers in the range 0-255 separated by periods (for example, "192.168.1.2"), known as dotted-quad notation.
[Note: The address space is fragmented into different types determined by bits 31-28 as shown in the following table.
]
Bits 31-28 Address type 0xxx class A 10xx class B 110x class C 1110 multicast 1111 reserved Instances of the IPAddress class are provided for common IP address values as shown in the following table.
Field IP Address Any 0.0.0.0 Broadcast 255.255.255.255 Loopback 127.0.0.1 None 255.255.255.255
System.Net Namespace
IPAddress Constructors
IPAddress Methods
IPAddress.Equals Method
IPAddress.GetHashCode Method
IPAddress.HostToNetworkOrder(long) Method
IPAddress.HostToNetworkOrder(int) Method
IPAddress.HostToNetworkOrder(short) Method
IPAddress.IsLoopback Method
IPAddress.NetworkToHostOrder(long) Method
IPAddress.NetworkToHostOrder(int) Method
IPAddress.NetworkToHostOrder(short) Method
IPAddress.Parse Method
IPAddress.ToString Method
IPAddress Fields
IPAddress.Any Field
IPAddress.Broadcast Field
IPAddress.Loopback Field
IPAddress.None Field
IPAddress Properties
public IPAddress(long newAddress);
Constructs and initializes a new instance of the IPAddress class.
- newAddress
- A Int64 containing the IP address in host-byte-order.
Exception Type Condition ArgumentOutOfRangeException newAddress is less than 0 or greater than 0x00000000FFFFFFFF.
System.Net.IPAddress Class, System.Net Namespace
public override bool Equals(object comparand);
Determines whether the current instance and the specified Object represent the same IP address.
- comparand
- A Object to compare to the current instance.
A Boolean wheretrue
indicates comparand is an instance of the IPAddress class and has the same System.Net.IPAddress.Address property value as the current instance; otherwisefalse
.
[Note: This method overrides System.Object.Equals(System.Object).]
System.Net.IPAddress Class, System.Net Namespace
public override int GetHashCode();
Generates a hash code for the current instance.
A Int32 containing the hash code for the current instance.
The algorithm used to generate the hash code is unspecified.[Note: This method overrides System.Object.GetHashCode.
]
System.Net.IPAddress Class, System.Net Namespace
public static long HostToNetworkOrder(long host);
Converts a Int64 from host-byte-order to network-byte-order.
- host
- A Int64 in host-byte-order.
A Int64 in network-byte-order.
This method performs conversions on systems where the host-byte-order differs from network-byte-order. On systems where this is not the case, this method does nothing.
System.Net.IPAddress Class, System.Net Namespace
public static int HostToNetworkOrder(int host);
Converts a Int32 from host-byte-order to network-byte-order.
- host
- A Int32 in host-byte-order.
A Int32 in network-byte-order.
This method performs conversions on systems where the host-byte-order differs from network-byte-order. On systems where this is not the case, this method does nothing.
System.Net.IPAddress Class, System.Net Namespace
public static short HostToNetworkOrder(short host);
Converts a Int16 from host-byte-order to network-byte-order.
- host
- A Int16 in host-byte-order.
A Int16 in network-byte-order.
This method performs conversions on systems where the host-byte-order differs from network-byte-order. On systems where this is not the case, this method does nothing.
System.Net.IPAddress Class, System.Net Namespace
public static bool IsLoopback(IPAddress address);
Returns a Boolean that indicates whether the specified IP address is a loopback address.
- address
- A IPAddress containing the IP address to check.
true
if address is a loopback address; otherwisefalse
.
All IP addresses of the form 127.X.Y.Z, where X, Y, and Z are in the range 0-255, are forwarded to the IP loopback address 127.0.0.1. The System.Net.IPAddress.Loopback address is used to specify the address of the local computer.
System.Net.IPAddress Class, System.Net Namespace
public static long NetworkToHostOrder(long network);
Converts a Int64 from network-byte-order to host-byte-order.
- network
- A Int64 in network-byte-order.
A Int64 in host-byte-order.
This method performs conversions on systems where the host-byte-order differs from network-byte-order. On systems where this is not the case, this method does nothing.
System.Net.IPAddress Class, System.Net Namespace
public static int NetworkToHostOrder(int network);
Converts a Int32 from network-byte-order to host-byte-order.
- network
- A Int32 in network-byte-order.
A Int32 in host-byte-order.
This method performs conversions on systems where the host-byte-order differs from network-byte-order. On systems where this is not the case, this method does nothing.
System.Net.IPAddress Class, System.Net Namespace
public static short NetworkToHostOrder(short network);
Converts a Int16 from network-byte-order to host-byte-order.
- network
- A Int16 in network-byte-order.
A Int16 in host-byte-order.
This method performs conversions on systems where the host-byte-order differs from network-byte-order. On systems where this is not the case, this method does nothing.
System.Net.IPAddress Class, System.Net Namespace
public static IPAddress Parse(string ipString);
Converts a String representation of an IP address in dotted-quad notation, to a IPAddress instance.
- ipString
- A String in dotted-quad notation containing the IP address to convert.
A new IPAddress instance that represents the address specified in ipString.
Exception Type Condition ArgumentNullException ipString is null
.FormatException ipString is not a valid IP address.
[Note: An example of a string in dotted-quad notation is "127.0.0.1".]
System.Net.IPAddress Class, System.Net Namespace
public override string ToString();
Returns a String representation of the value of the current instance.
A String representation of the current instance. The returned string is an IP address expressed in dotted-quad notation (for example, "192.168.1.2").
[Note: The System.Net.IPAddress.ToString method converts the IP address stored in the System.Net.IPAddress.Address property of the current instance to a String containing the address in dotted-quad notation (for example, "192.168.1.2").This method overrides System.Object.ToString.
]
System.Net.IPAddress Class, System.Net Namespace
public static readonly IPAddress Any;
Indicates that the protocol will select which address to use.
This field is read-only.This is equivalent to System.Net.IPAddress.IPAddress (0x0000000000000000) and represents the address 0.0.0.0.
System.Net.IPAddress Class, System.Net Namespace
public static readonly IPAddress Broadcast;
Provides the IP broadcast address.
This field is read-only.This is equivalent to System.Net.IPAddress.IPAddress (0x00000000FFFFFFFF) and represents the address 255.255.255.255.
This value is used to simultaneously address every host on the network.
[Note: Multiple fields are defined for this IP address based on prior art. This field is identical to System.Net.IPAddress.None.
]
System.Net.IPAddress Class, System.Net Namespace
public static readonly IPAddress Loopback;
Provides the IP loopback address.
This field is read-only.This is equivalent to System.Net.IPAddress.IPAddress (0x000000000100007F) and represents the address 127.0.0.1.
The loopback address is used to specify the address of the local computer.
System.Net.IPAddress Class, System.Net Namespace
public static readonly IPAddress None;
Provides the IP address that indicates that no network interface should be used.
This field is read-only.This is equivalent to System.Net.IPAddress.IPAddress (0x00000000FFFFFFFF) and represents the address 255.255.255.255.
[Note: Multiple fields are defined for this IP address based on prior art. This field is identical to System.Net.IPAddress.Broadcast.
]
System.Net.IPAddress Class, System.Net Namespace
public long Address { get; set; }
Gets or sets an Internet Protocol (IP) address.
A Int64 containing the IP address in host-byte-order.
Exception Type Condition ArgumentOutOfRangeException The value specified in a set operation is less than 0.
[Note: To convert System.Net.IPAddress.Address to dotted-quad notation, use the System.Net.IPAddress.ToString method.Values greater than 0x00000000FFFFFFFF are permitted for IPv6 extensibility.
]
System.Net.IPAddress Class, System.Net Namespace
public AddressFamily AddressFamily { get; }
Gets the address family.
System.Net.Sockets.AddressFamily.InterNetwork .
This property is read-only.
System.Net.IPAddress Class, System.Net Namespace