ntohl function (winsock2.h)

The ntohl function converts a u_long from TCP/IP network order to host byte order (which is little-endian on Intel processors).

Syntax

u_long WSAAPI ntohl(
  [in] u_long netlong
);

Parameters

[in] netlong

A 32-bit number in TCP/IP network byte order.

Return value

The ntohl function returns the value supplied in the netlong parameter with the byte order reversed. If netlong is already in host byte order, then this function will reverse it. It is up to the application to determine if the byte order must be reversed.

Remarks

The ntohl function takes a 32-bit number in TCP/IP network byte order (the AF_INET or AF_INET6 address family) and returns a 32-bit number in host byte order.

The ntohl function can be used to convert an IPv4 address in network byte order to the IPv4 address in host byte order. This function does not do any checking to determine if the netlong parameter is a valid IPv4 address.

The ntohl function does not require that the Winsock DLL has previously been loaded with a successful call to the WSAStartup function.

Windows 8.1 and Windows Server 2012 R2: This function is supported for Windows Store apps on Windows 8.1, Windows Server 2012 R2, and later.

Requirements

Requirement Value
Minimum supported client Windows 8.1, Windows Vista [desktop apps | UWP apps]
Minimum supported server Windows Server 2003 [desktop apps | UWP apps]
Target Platform Windows
Header winsock2.h (include Winsock2.h)
Library Ws2_32.lib
DLL Ws2_32.dll

See also

InetNtop

InetPton

WSAHtonl

WSAHtons

WSANtohl

WSANtohs

htond

htonf

htonl

htonll

htons

inet_addr

inet_ntoa

ntohd

ntohf

ntohs