Επεξεργασία

Κοινή χρήση μέσω


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.

public:
 static short NetworkToHostOrder(short network);
public static short NetworkToHostOrder (short network);
static member NetworkToHostOrder : int16 -> int16
Public Shared Function NetworkToHostOrder (network As Short) As Short

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.

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 );
}
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);
}
Public Sub NetworkToHostOrder_Short(networkByte As Short)
    Dim hostByte As Short
    ' 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)
End Sub

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

NetworkToHostOrder(Int32)

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

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

public:
 static int NetworkToHostOrder(int network);
public static int NetworkToHostOrder (int network);
static member NetworkToHostOrder : int -> int
Public Shared Function NetworkToHostOrder (network As Integer) As Integer

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.

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 );
}
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);
}
Public Sub NetworkToHostOrder_Integer(networkByte As Integer)
    Dim hostByte As Integer
    ' 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)
End Sub

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

NetworkToHostOrder(Int64)

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

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

public:
 static long NetworkToHostOrder(long network);
public static long NetworkToHostOrder (long network);
static member NetworkToHostOrder : int64 -> int64
Public Shared Function NetworkToHostOrder (network As Long) As Long

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.

void NetworkToHostOrder_Long( __int64 networkByte )
{
   __int64 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 );
}
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);
}
Public Sub NetworkToHostOrder_Long(networkByte As Long)
    Dim hostByte As Long
    ' 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)
End Sub

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