IPAddress.NetworkToHostOrder IPAddress.NetworkToHostOrder IPAddress.NetworkToHostOrder IPAddress.NetworkToHostOrder Method

定义

将数字由网络字节顺序转换为主机字节顺序。Converts a number from network byte order to host byte order.

重载

NetworkToHostOrder(Int32) NetworkToHostOrder(Int32) NetworkToHostOrder(Int32) NetworkToHostOrder(Int32)

将整数值由网络字节顺序转换为主机字节顺序。Converts an integer value from network byte order to host byte order.

NetworkToHostOrder(Int64) NetworkToHostOrder(Int64) NetworkToHostOrder(Int64) NetworkToHostOrder(Int64)

将长值由网络字节顺序转换为主机字节顺序。Converts a long value from network byte order to host byte order.

NetworkToHostOrder(Int16) NetworkToHostOrder(Int16) NetworkToHostOrder(Int16) NetworkToHostOrder(Int16)

将短值由网络字节顺序转换为主机字节顺序。Converts a short value from network byte order to host byte order.

NetworkToHostOrder(Int32) NetworkToHostOrder(Int32) NetworkToHostOrder(Int32) NetworkToHostOrder(Int32)

将整数值由网络字节顺序转换为主机字节顺序。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

参数

network
Int32 Int32 Int32 Int32

以网络字节顺序表示的要转换的数字。The number to convert, expressed in network byte order.

返回

以主机字节顺序表示的整数值。An integer value, expressed in host byte order.

示例

下面的示例使用NetworkToHostOrder方法将整数值由网络字节顺序转换为主机字节顺序。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

注解

不同的计算机使用不同的约定对多字节整数值中的字节进行排序。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.

NetworkToHostOrder方法将主机系统上存储的多字节整数值从网络使用的字节顺序转换为主机使用的字节顺序。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.

另请参阅

NetworkToHostOrder(Int64) NetworkToHostOrder(Int64) NetworkToHostOrder(Int64) NetworkToHostOrder(Int64)

将长值由网络字节顺序转换为主机字节顺序。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

参数

network
Int64 Int64 Int64 Int64

以网络字节顺序表示的要转换的数字。The number to convert, expressed in network byte order.

返回

以主机字节顺序表示的长值。A long value, expressed in host byte order.

示例

下面的示例使用NetworkToHostOrder方法将长值由网络字节顺序转换为主机字节顺序。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

注解

不同的计算机使用不同的约定对多字节整数值中的字节进行排序。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.

NetworkToHostOrder方法将主机系统上存储的多字节整数值从网络使用的字节顺序转换为主机使用的字节顺序。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.

另请参阅

NetworkToHostOrder(Int16) NetworkToHostOrder(Int16) NetworkToHostOrder(Int16) NetworkToHostOrder(Int16)

将短值由网络字节顺序转换为主机字节顺序。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

参数

network
Int16 Int16 Int16 Int16

以网络字节顺序表示的要转换的数字。The number to convert, expressed in network byte order.

返回

以主机字节顺序表示的短值。A short value, expressed in host byte order.

示例

下面的示例使用NetworkToHostOrder方法将短值由网络字节顺序转换为主机字节顺序。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

注解

不同的计算机使用不同的约定对多字节整数值中的字节进行排序。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.

NetworkToHostOrder方法将主机系统上存储的多字节整数值从网络使用的字节顺序转换为主机使用的字节顺序。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.

另请参阅

适用于