ntohl 函式 (winsock.h)

ntohl函式會將u_long從 TCP/IP 網路順序轉換成主機位元組順序 (,這是 Intel 處理器) 的位元組順序。

語法

u_long ntohl(
  [in] u_long netlong
);

參數

[in] netlong

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

傳回值

ntohl函式會傳回netlong參數中提供的值,並反轉位元組順序。 如果 netlong 已經以主機位元組順序排列,則此函式會反轉它。 由應用程式決定位元組順序是否必須反轉。

備註

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

ntohl函式可用來將網路位元組順序中的 IPv4 位址轉換為主機位元組順序中的 IPv4 位址。 此函式不會進行任何檢查,以判斷 netlong 參數是否為有效的 IPv4 位址。

ntohl函式不需要先前已載入 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

ntohs