Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

WSANtohl function

The WSANtohl function converts a u_long from network byte order to host byte order.

Syntax


int WSAAPI WSANtohl(
  _In_   SOCKET s,
  _In_   u_long netlong,
  _Out_  u_long *lphostlong
);

Parameters

s [in]

A descriptor identifying a socket.

netlong [in]

A 32-bit number in network byte order.

lphostlong [out]

A pointer to a 32-bit number to receive the number in host byte order.

Return value

If no error occurs, WSANtohl returns zero. Otherwise, a value of SOCKET_ERROR is returned, and a specific error code can be retrieved by calling WSAGetLastError.

Error codeMeaning
WSANOTINITIALISED

A successful WSAStartup call must occur before using this function.

WSAENETDOWN

The network subsystem has failed.

WSAENOTSOCK

The descriptor is not a socket.

WSAEFAULT

The lphostlong parameter is NULL or the address pointed to is not completely contained in a valid part of the user address space.

 

Remarks

The WSANtohl function takes a 32-bit number in network byte order and returns a 32-bit number in host byte order in the 32-bit number pointed to by the lphostlong parameter. The socket passed in the s parameter is used to determine the network byte order required based on the Winsock catalog protocol entry associated with the socket. This feature supports Winsock providers that use different network byte orders.

If the socket is for the AF_INET or AF_INET6 address family, the WSANtohl 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 WSANtohl function requires that the Winsock DLL has previously been loaded with a successful call to the WSAStartup function. For use with the AF_INET or AF_INET6 family, the ntohl function does not require that the Winsock DLL be loaded.

Windows Phone 8: This API is supported.

Requirements

Minimum supported client

Windows Vista [desktop apps only]

Minimum supported server

Windows Server 2003 [desktop apps only]

Minimum supported phone

Windows Phone 8

Header

Winsock2.h

Library

Ws2_32.lib

DLL

Ws2_32.dll

See also

Winsock Reference
Winsock Functions
htonl
htons
inet_addr
inet_ntoa
InetNtop
ntohl
ntohs
WSAHtonl
WSAHtons
WSANtohs

 

 

Community Additions

Show:
© 2014 Microsoft