Class Address
Address class, used to define a IPv4 address.
Inheritance
Implements
Inherited Members
Namespace: Cosmos.System.Network.IPv4
Assembly: Cosmos.System2.dll
Syntax
public class Address : IComparable
Constructors
| Improve this Doc View SourceAddress(Byte, Byte, Byte, Byte)
Create new instance of the Address class, with specified IP address.
Declaration
public Address(byte aFirst, byte aSecond, byte aThird, byte aFourth)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | aFirst | First block of the address. |
System.Byte | aSecond | Second block of the address. |
System.Byte | aThird | Third block of the address. |
System.Byte | aFourth | Fourth block of the address. |
Address(Byte[], Int32)
Create new instance of the Address class, with specified buffer and offset.
Declaration
public Address(byte[] buffer, int offset)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | buffer | Buffer. |
System.Int32 | offset | Offset. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | Thrown if buffer is invalid or null. |
Fields
| Improve this Doc View SourceBroadcast
Broadcast address (255.255.255.255).
Declaration
public static Address Broadcast
Field Value
Type | Description |
---|---|
Address |
Zero
Predefined 0.0.0.0 address.
Declaration
public static Address Zero
Field Value
Type | Description |
---|---|
Address |
Properties
| Improve this Doc View SourceHash
Hash value for this IP. Used to uniquely identify each IP
Declaration
public uint Hash { get; }
Property Value
Type | Description |
---|---|
System.UInt32 |
Methods
| Improve this Doc View SourceCIDRToAddress(Int32)
Convert CIDR number to IPv4 Address
Declaration
public static Address CIDRToAddress(int cidr)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | cidr | CIDR number. |
Returns
Type | Description |
---|---|
Address |
CompareTo(Object)
Compare 2 IP Address objects for equality
Declaration
public int CompareTo(object obj)
Parameters
Type | Name | Description |
---|---|---|
System.Object | obj | Other IP to compare with. |
Returns
Type | Description |
---|---|
System.Int32 | 0 if equal, or non-zero otherwise |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | Thrown if obj is not a IPv4Address. |
IsAPIPA()
Check if address is a APIPA address.
Declaration
public bool IsAPIPA()
Returns
Type | Description |
---|---|
System.Boolean |
IsBroadcastAddress()
Check if address is a broadcast address.
Declaration
public bool IsBroadcastAddress()
Returns
Type | Description |
---|---|
System.Boolean |
IsLoopbackAddress()
Check if address is a loopback address.
Declaration
public bool IsLoopbackAddress()
Returns
Type | Description |
---|---|
System.Boolean |
Parse(String)
Parse a IP address in string representation.
Declaration
public static Address Parse(string adr)
Parameters
Type | Name | Description |
---|---|---|
System.String | adr | IP address as string. |
Returns
Type | Description |
---|---|
Address | Address value. |
Exceptions
Type | Condition |
---|---|
System.OverflowException | Thrown if adr is longer than Int32.MaxValue. |
System.ArgumentNullException | Thrown if adr is null. |
System.FormatException | Thrown if adr is not in the right format. |
System.OverflowException | Thrown if adr represents a number less than Byte.MinValue or greater than Byte.MaxValue. |
ToByteArray()
Convert address to byte array.
Declaration
public byte[] ToByteArray()
Returns
Type | Description |
---|---|
System.Byte[] |
ToString()
Converts IP Address to String.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String | String with IP Address in dotted notation |