Description





Description

An instance of the IPAddress class contains the value of an address on an IP network. This address is stored internally as a System.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.]

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


Example
using System;

using System.Net;





public class IPAddressSample

{

    public static void Main()

    {

        IPAddress addr1 = IPAddress.Parse("10.0.0.1");

        Console.WriteLine("IPAddress = '{0}'",

            addr1);

        Console.WriteLine("IPAddress.AddressFamily = '{0}'",

            addr1.AddressFamily);

        Console.WriteLine("IPAddress.IsLoopback(10.0.0.1) = '{0}'",

            IPAddress.IsLoopback(addr1));

        IPAddress addr2 = IPAddress.Loopback;

        Console.WriteLine("IPAddress.IsLoopback(127.0.0.1) = '{0}'",

            IPAddress.IsLoopback(addr2));

        Console.WriteLine("IPAddress.(10.0.0.1) == "

            + "IPAddress(127.0.0.1) ? = {0}",

            addr1.Equals(addr2));

        Console.WriteLine();

        Console.WriteLine();

        Console.WriteLine("Press Enter to continue");

        Console.ReadLine();

    }

}




The output is

IPAddress = '10.0.0.1'

IPAddress.AddressFamily = 'InterNetwork'

IPAddress.IsLoopback(10.0.0.1) = 'False'

IPAddress.IsLoopback(127.0.0.1) = 'True'

IPAddress.(10.0.0.1) == IPAddress(127.0.0.1) ? = False





Press Enter to continue



     Python   SQL   Java   php   Perl 
     game development   web development   internet   *nix   graphics   hardware 
     telecommunications   C++ 
     Flash   Active Directory   Windows