IPAddress.HostToNetworkOrder Method

Definition

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

Overloads

HostToNetworkOrder(Int64)

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

HostToNetworkOrder(Int16)

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

HostToNetworkOrder(Int32)

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

HostToNetworkOrder(Int64)

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

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

C#
public static long HostToNetworkOrder(long host);

Parameters

host
Int64

The number to convert, expressed in host byte order.

Returns

A long value, expressed in network byte order.

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 HostToNetworkOrder method converts multibyte integer values that are stored on the host system from the byte order used by the host to the byte order used by the network.

See also

Applies to

.NET 10 and other versions
Product Versions
.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

HostToNetworkOrder(Int16)

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

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

C#
public static short HostToNetworkOrder(short host);

Parameters

host
Int16

The number to convert, expressed in host byte order.

Returns

A short value, expressed in network byte order.

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 HostToNetworkOrder method converts multibyte integer values that are stored on the host system from the byte order used by the host to the byte order used by the network.

See also

Applies to

.NET 10 and other versions
Product Versions
.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

HostToNetworkOrder(Int32)

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

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

C#
public static int HostToNetworkOrder(int host);

Parameters

host
Int32

The number to convert, expressed in host byte order.

Returns

An integer value, expressed in network byte order.

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 HostToNetworkOrder method converts multibyte integer values that are stored on the host system from the byte order used by the host to the byte order used by the network.

See also

Applies to

.NET 10 and other versions
Product Versions
.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