IPAddress.NetworkToHostOrder 方法

定義

將數字從網路位元組順序轉換為主機位元組順序。Converts a number 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)

將短整數值從網路位元組順序轉換為主機位元組順序。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.

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

以網路位元組順序表示之要轉換的數字。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)

將長整數值從網路位元組順序轉換為主機位元組順序。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

以網路位元組順序表示之要轉換的數字。The number to convert, expressed in network byte order.

傳回

以主機位元組順序表示的長整數值。A long value, expressed in host byte order.

範例

下列範例會使用 NetworkToHostOrder 方法,將 long 值從網路位元組順序轉換成主機位元組順序。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)

將短整數值從網路位元組順序轉換為主機位元組順序。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

以網路位元組順序表示之要轉換的數字。The number to convert, expressed in network byte order.

傳回

以主機位元組順序表示的短整數值。A short value, expressed in host byte order.

範例

下列範例會使用 NetworkToHostOrder 方法,將 short 值從網路位元組順序轉換成主機位元組順序。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.

另請參閱

適用於