IPAddress.HostToNetworkOrder : IP Address « Network « C# / CSharp Tutorial






using System;
using System.Net;
using System.Text;

class MainClass
{
   public static void Main()
   {
      short test1 = 45;
      int test2 = 314159;
      long test3 = -123456789033452;
      byte[] data = new byte[1024];
      string output;

      short test1b = IPAddress.HostToNetworkOrder(test1);
      data = BitConverter.GetBytes(test1b);
      output = BitConverter.ToString(data);
      Console.WriteLine("test1 = {0}, nbo = {1}", test1b, output);

      int test2b = IPAddress.HostToNetworkOrder(test2);
      data = BitConverter.GetBytes(test2b);
      output = BitConverter.ToString(data);
      Console.WriteLine("test2 = {0}, nbo = {1}", test2b, output);

      long test3b = IPAddress.HostToNetworkOrder(test3);
      data = BitConverter.GetBytes(test3b);
      output = BitConverter.ToString(data);
      Console.WriteLine("test3 = {0}, nbo = {1}", test3b, output);
   }
}








33.1.IP Address
33.1.1.Create(parse) IP address from string
33.1.2.IPAddress.Loopback
33.1.3.IPAddress.Broadcast
33.1.4.IPAddress.Any
33.1.5.IPAddress.None
33.1.6.Is Loopback IP address
33.1.7.Create IPEndPoint from IPAddress
33.1.8.Get Address Family, address and port from an IPEndPoint
33.1.9.Set Port for an IPEndPoint
33.1.10.Serialize a SocketAddress from a IPEndPoint
33.1.11.IPEndPoint: MinPort and MaxPort
33.1.12.Get Alias from IPHostEntry
33.1.13.IPAddress.HostToNetworkOrder