IPAddress.NetworkToHostOrder Method

Definition

Converts a number from network byte order to host byte order.

Overloads

NetworkToHostOrder(Int16)

Converts a short value from network byte order to host byte order.

NetworkToHostOrder(Int32)

Converts an integer value from network byte order to host byte order.

NetworkToHostOrder(Int64)

Converts a long value from network byte order to host byte order.

NetworkToHostOrder(Int16)

Source:
IPAddress.cs
Source:
IPAddress.cs
Source:
IPAddress.cs

Converts a short value from network byte order to host byte order.

C#
public static short NetworkToHostOrder(short network);

Parameters

network
Int16

The number to convert, expressed in network byte order.

Returns

A short value, expressed in host byte order.

Examples

The following example uses the NetworkToHostOrder method to convert a short value from network byte order to host byte order.

C#
public void NetworkToHostOrder_Short(short networkByte)
{
  short hostByte;
  // Converts a short value from network byte order to host byte order.
  hostByte = IPAddress.NetworkToHostOrder(networkByte);
  Console.WriteLine("Network byte order to Host byte order of {0} is {1}", networkByte, hostByte);
}

Remarks

Different computers use different conventions for ordering the bytes within multibyte integer values. Some computers put the most significant byte first (known as big-endian order) and others put the least-significant byte first (known as little-endian order). To work with computers that use different byte ordering, all integer values that are sent over the network are sent in network byte order which has the most significant byte first.

The NetworkToHostOrder method converts multibyte integer values that are stored on the host system from the byte order used by the network to the byte order used by the host.

See also

Applies to

.NET 10 a ďalšie verzie
Produkt Verzie
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0

NetworkToHostOrder(Int32)

Source:
IPAddress.cs
Source:
IPAddress.cs
Source:
IPAddress.cs

Converts an integer value from network byte order to host byte order.

C#
public static int NetworkToHostOrder(int network);

Parameters

network
Int32

The number to convert, expressed in network byte order.

Returns

An integer value, expressed in host byte order.

Examples

The following example uses the NetworkToHostOrder method to convert an integer value from network byte order to host byte order.

C#
public void NetworkToHostOrder_Integer(int networkByte)
{
  int hostByte;
  // Converts an integer value from network byte order to host byte order.
  hostByte = IPAddress.NetworkToHostOrder(networkByte);
  Console.WriteLine("Network byte order to Host byte order of {0} is {1}", networkByte, hostByte);
}

Remarks

Different computers use different conventions for ordering the bytes within multibyte integer values. Some computers put the most significant byte first (known as big-endian order) and others put the least-significant byte first (known as little-endian order). To work with computers that use different byte ordering, all integer values that are sent over the network are sent in network byte order which has the most significant byte first.

The NetworkToHostOrder method converts multibyte integer values that are stored on the host system from the byte order used by the network to the byte order used by the host.

See also

Applies to

.NET 10 a ďalšie verzie
Produkt Verzie
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0

NetworkToHostOrder(Int64)

Source:
IPAddress.cs
Source:
IPAddress.cs
Source:
IPAddress.cs

Converts a long value from network byte order to host byte order.

C#
public static long NetworkToHostOrder(long network);

Parameters

network
Int64

The number to convert, expressed in network byte order.

Returns

A long value, expressed in host byte order.

Examples

The following example uses the NetworkToHostOrder method to convert a long value from network byte order to host byte order.

C#
public void NetworkToHostOrder_Long(long networkByte)
{
  long hostByte;
  // Converts a long value from network byte order to host byte order.
  hostByte = IPAddress.NetworkToHostOrder(networkByte);
  Console.WriteLine("Network byte order to Host byte order of {0} is {1}", networkByte, hostByte);
}

Remarks

Different computers use different conventions for ordering the bytes within multibyte integer values. Some computers put the most significant byte first (known as big-endian order) and others put the least-significant byte first (known as little-endian order). To work with computers that use different byte ordering, all integer values that are sent over the network are sent in network byte order which has the most significant byte first.

The NetworkToHostOrder method converts multibyte integer values that are stored on the host system from the byte order used by the network to the byte order used by the host.

See also

Applies to

.NET 10 a ďalšie verzie
Produkt Verzie
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0