Class Address
Represents 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. |
Address(UInt32)
Create new instance of the Address class, with specified IP address.
Declaration
public Address(uint address)
Parameters
| Type | Name | Description |
|---|---|---|
| System.UInt32 | address | Adress |
Fields
| Improve this Doc View SourceBroadcast
The broadcast address (255.255.255.255).
Declaration
public static readonly Address Broadcast
Field Value
| Type | Description |
|---|---|
| Address |
Zero
The 0.0.0.0 IP address.
Declaration
public static readonly Address Zero
Field Value
| Type | Description |
|---|---|
| Address |
Properties
| Improve this Doc View SourceHash
The hash value for this IP. Used to uniquely identify each IP.
Declaration
public uint Hash { get; }
Property Value
| Type | Description |
|---|---|
| System.UInt32 |
IsIpv4
Declaration
public bool IsIpv4 { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
IsIpv6
Declaration
public bool IsIpv6 { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Methods
| Improve this Doc View SourceCIDRToAddress(Int32)
Convert a CIDR number to an IPv4 address.
Declaration
public static Address CIDRToAddress(int cidr)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | cidr | The CIDR number. |
Returns
| Type | Description |
|---|---|
| Address |
CompareTo(Object)
Declaration
public int CompareTo(object obj)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | obj |
Returns
| Type | Description |
|---|---|
| System.Int32 |
Equals(Object)
Declaration
public override bool Equals(object obj)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | obj |
Returns
| Type | Description |
|---|---|
| System.Boolean |
Overrides
IsAPIPA()
Check if this address is an APIPA address.
Declaration
public bool IsAPIPA()
Returns
| Type | Description |
|---|---|
| System.Boolean |
IsBroadcastAddress()
Check if this address is a broadcast address.
Declaration
public bool IsBroadcastAddress()
Returns
| Type | Description |
|---|---|
| System.Boolean |
IsLoopbackAddress()
Check if this address is a loopback address.
Declaration
public bool IsLoopbackAddress()
Returns
| Type | Description |
|---|---|
| System.Boolean |
Parse(String)
Parses a IP address in its string representation.
Declaration
public static Address Parse(string addr)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | addr | The IP address as string. |
Returns
| Type | Description |
|---|---|
| Address | The parsed address value. |
Exceptions
| Type | Condition |
|---|---|
| System.OverflowException | Thrown if addr is longer than System.Int32.MaxValue. |
| System.ArgumentNullException | Thrown if addr is null. |
| System.FormatException | Thrown if addr is not in the right format. |
| System.OverflowException | Thrown if addr represents a number less than Byte.MinValue or greater than System.Byte.MaxValue. |
ToByteArray()
Returns the underlying parts array. Modifying the returned array will also modify the address.
Declaration
public byte[] ToByteArray()
Returns
| Type | Description |
|---|---|
| System.Byte[] |
ToString()
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| System.String |
Overrides
ToUInt32()
Convert this address to a 32-bit number.
Declaration
public uint ToUInt32()
Returns
| Type | Description |
|---|---|
| System.UInt32 |