ntohs 函式 (winsock.h)

ntohs函式會將u_short從 TCP/IP 網路位元組順序轉換成裝載位元組順序 (,這在 Intel 處理器) 上很少端。

語法

u_short ntohs(
  [in] u_short netshort
);

參數

[in] netshort

TCP/IP 網路位元組順序中的 16 位數位。

傳回值

ntohs函式會以主機位元組順序傳回值。 如果 netshort 參數已經在主機位元組順序中,則此函式會反轉它。 應用程式必須判斷位元組順序是否必須反轉。

備註

ntohs函式會採用 TCP/IP 網路位元組順序中的 16 位數位, (AF_INET或AF_INET6位址系列) ,並以主機位元組順序傳回 16 位的數位。

ntohs函式可用來將網路位元組順序中的 IP 埠號碼轉換為主機位元組順序中的 IP 埠號碼。

ntohs函式不需要先前已載入 Winsock DLL,且已成功呼叫WSAStartup函式。

Windows 8.1Windows Server 2012 R2:Windows 市集應用程式支援此功能,Windows 8.1、Windows Server 2012 R2 及更新版本。

規格需求

   
最低支援的用戶端 Windows 8.1、Windows Vista [傳統型應用程式 |UWP 應用程式]
最低支援的伺服器 Windows Server 2003 [傳統型應用程式 |UWP 應用程式]
目標平台 Windows
標頭 winsock.h (包含 Winsock2.h)
程式庫 Ws2_32.lib
Dll Ws2_32.dll

另請參閱

InetNtop

InetPton

WSAHtonl

WSAHtons

WSANtohl

WSANtohs

htond

htonf

htonl

htonll

htons

inet_addr

inet_ntoa

ntohd

ntohf

ntohl

ntohll